]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление обработки карточки ви внешней картинки
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 11 Aug 2025 13:55:29 +0000 (16:55 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 11 Aug 2025 13:55:29 +0000 (16:55 +0300)
erp24/controllers/MatrixErpPropertyController.php
erp24/migrations/m250811_135208_increase_columns_length_to_255_in_matrix_erp_property.php [new file with mode: 0644]
erp24/records/MatrixErpProperty.php

index 8e63f6ee3ddf22a6baf7837aef45b5abae6003f8..5ec32f562aa9b6c17aa8246b58429b6579438b3e 100644 (file)
@@ -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 (file)
index 0000000..f9bb925
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+use yii\db\Migration;
+
+class m250811_135208_increase_columns_length_to_255_in_matrix_erp_property extends Migration
+{
+    const TABLE_NAME = 'erp24.matrix_erp_property';
+
+    /** @inheritDoc */
+    public function safeUp()
+    {
+        $columns = [
+            'external_image_url',
+            'product_url',
+        ];
+
+        foreach ($columns as $col) {
+            $this->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
index d11a110cb1b10b35d5363f6e3464473f8a4936e8..66ca901e0ac1de3d6067eb3cdd9635554d89a92e 100644 (file)
@@ -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],
         ];
     }