From: Vladimir Fomichev Date: Mon, 11 Aug 2025 13:27:15 +0000 (+0300) Subject: Добавление обработки карточки ви внешней картинки X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7fb8616125c91e74feda3d73314a125d208b3843;p=erp24_rep%2Fyii-erp24%2F.git Добавление обработки карточки ви внешней картинки --- diff --git a/erp24/controllers/MatrixErpPropertyController.php b/erp24/controllers/MatrixErpPropertyController.php index 87d647df..b24d2926 100644 --- a/erp24/controllers/MatrixErpPropertyController.php +++ b/erp24/controllers/MatrixErpPropertyController.php @@ -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(); } diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index 0e2103f7..3d24d618 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -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); }