]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление обработки карточки ви внешней картинки
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 11 Aug 2025 13:27:15 +0000 (16:27 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 11 Aug 2025 13:27:15 +0000 (16:27 +0300)
erp24/controllers/MatrixErpPropertyController.php
erp24/services/MarketplaceService.php

index 87d647dffa2c58df15325067705ab675ecf88a18..b24d292651f228d60e73a36f7b227856ee2016fb 100644 (file)
@@ -19,6 +19,7 @@ use yii\web\NotFoundHttpException;
 use yii\filters\VerbFilter;
 use yii_app\records\MultipleModel;
 use yii_app\services\FileService;
+use yii_app\services\MarketplaceService;
 
 /**
  * MatrixErpPropertyController implements the CRUD actions for MatrixErpProperty model.
@@ -127,7 +128,7 @@ class MatrixErpPropertyController extends Controller
                     $modelEdit->created_admin_id = $adminId;
                 }
 
-                $modelEdit->product_url ='/media/view-card?guid=' . $modelEdit->guid;
+                $modelEdit->product_url = MarketplaceService::getProductLinkByGuid($modelEdit->guid);
 
                 if (!empty($modelEdit->image_id)) {
                     $oldFile = Images::find()->where(['id' => $modelEdit->image_id])->one();
@@ -226,7 +227,7 @@ class MatrixErpPropertyController extends Controller
 
                                 if (!empty($imageId)) {
                                     $modelEdit->image_id = $imageId;
-                                    $modelEdit->external_image_url =  '/media/view-image?id=' . $imageId;
+                                    $modelEdit->external_image_url =  MarketplaceService::getProductImageUrl($imageId);
                                     if (!empty($oldFile)) {
                                         $oldFile->delete();
                                     }
index 0e2103f70a2875981c4d05bbaab4725bd94ccb55..3d24d6187db6650c01c47adb8afa87d7713114b3 100644 (file)
@@ -641,14 +641,14 @@ class MarketplaceService
             'imageUrl' => self::getProductImageUrl($product->image_id),
             'date' => $product->date,
             'displayName' => $product->display_name,
-            'externalImageUrl' => $product->external_image_url,
-            'productUrl' => $product->product_url,
+            'externalImageUrl' => $product->external_image_url ?? self::getProductImageUrl($product->image_id),
+            'productUrl' => $product->product_url  ?? self::getProductLinkByGuid($product->guid),
             'flowwowCategory' => $product->flowwow_category,
             'flowwowSubcategory' => $product->flowwow_subcategory,
         ];
     }
 
-    private static function getProductImageUrl($imageId)
+    public static function getProductImageUrl($imageId)
     {
         $image = Images::findOne($imageId);
         $fileName = '';
@@ -661,7 +661,7 @@ class MarketplaceService
         return null;
     }
 
-    private static function getProductLinkByGuid($guid)
+    public static function getProductLinkByGuid($guid)
     {
         return 'https://media.erp-flowers.ru/media/view-card?guid=' . urlencode($guid);
     }