From: Vladimir Fomichev Date: Mon, 11 Aug 2025 13:55:29 +0000 (+0300) Subject: Добавление обработки карточки ви внешней картинки X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=cdcf347d60a612fe8dcfc63858faa997db980bf3;p=erp24_rep%2Fyii-erp24%2F.git Добавление обработки карточки ви внешней картинки --- 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], ]; }