From cdcf347d60a612fe8dcfc63858faa997db980bf3 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Mon, 11 Aug 2025 16:55:29 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D0=B5=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?utf8?q?=D0=B8=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=BA=D0=B8=20?= =?utf8?q?=D0=B2=D0=B8=20=D0=B2=D0=BD=D0=B5=D1=88=D0=BD=D0=B5=D0=B9=20?= =?utf8?q?=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../MatrixErpPropertyController.php | 8 ++++- ...s_length_to_255_in_matrix_erp_property.php | 34 +++++++++++++++++++ erp24/records/MatrixErpProperty.php | 4 +-- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 erp24/migrations/m250811_135208_increase_columns_length_to_255_in_matrix_erp_property.php diff --git a/erp24/controllers/MatrixErpPropertyController.php b/erp24/controllers/MatrixErpPropertyController.php index 8e63f6ee..5ec32f56 100644 --- a/erp24/controllers/MatrixErpPropertyController.php +++ b/erp24/controllers/MatrixErpPropertyController.php @@ -236,10 +236,16 @@ class MatrixErpPropertyController extends Controller if (!empty($oldFile)) { $oldFile->delete(); } - $modelEdit->save(); + if (!$modelEdit->save()){ + Yii::error("Ошибка созранения ссылок на картинки " . json_encode($modelEdit->getErrors(), JSON_UNESCAPED_UNICODE)); + } } } } + if ($modelEdit->image_id) { + $modelEdit->external_image_url = MarketplaceService::getProductImageUrl($modelEdit->image_id); + } + } return $this->redirect(['matrix-erp/view', 'id' => $matrixErpId]); diff --git a/erp24/migrations/m250811_135208_increase_columns_length_to_255_in_matrix_erp_property.php b/erp24/migrations/m250811_135208_increase_columns_length_to_255_in_matrix_erp_property.php new file mode 100644 index 00000000..f9bb925a --- /dev/null +++ b/erp24/migrations/m250811_135208_increase_columns_length_to_255_in_matrix_erp_property.php @@ -0,0 +1,34 @@ +alterColumn(self::TABLE_NAME, $col, $this->string(255)->null()); + } + } + + /** @inheritDoc */ + public function safeDown() + { + $columns = [ + 'external_image_url', + 'product_url', + ]; + + foreach ($columns as $col) { + $this->alterColumn(self::TABLE_NAME, $col, $this->string(100)->null()); + } + } +} \ No newline at end of file diff --git a/erp24/records/MatrixErpProperty.php b/erp24/records/MatrixErpProperty.php index d11a110c..66ca901e 100644 --- a/erp24/records/MatrixErpProperty.php +++ b/erp24/records/MatrixErpProperty.php @@ -57,8 +57,8 @@ class MatrixErpProperty extends \yii\db\ActiveRecord 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg', 'checkExtensionByMimeType' => false ], [['mediaFile', 'id', 'display_name', 'external_image_url', 'product_url', 'flowwow_category', 'flowwow_subcategory',], 'safe'], - [['guid', 'date', 'created_at', 'updated_at', 'display_name', 'external_image_url', 'product_url', 'flowwow_category', 'flowwow_subcategory'], 'string', 'max' => 100], - [['url_link_video'], 'string', 'max' => 255], + [['guid', 'date', 'created_at', 'updated_at', 'display_name', 'flowwow_category', 'flowwow_subcategory'], 'string', 'max' => 100], + [['url_link_video', 'external_image_url', 'product_url'], 'string', 'max' => 255], ]; } -- 2.39.5