]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Оставляем в фиде активные товары feature_fomichev_erp-472_add_feed_activity_to_matrix_erp
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 2 Oct 2025 12:29:09 +0000 (15:29 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 2 Oct 2025 12:29:09 +0000 (15:29 +0300)
erp24/services/MarketplaceService.php

index 34c00bac032b9577cdb5918bbb42fd0281ebada6..52d816400ac7344dfc812b8b956a2f10edb2a7e5 100644 (file)
@@ -29,6 +29,7 @@ use yii_app\records\MarketplaceOrderStatusHistory;
 use yii_app\records\MarketplaceOrderStatusTypes;
 use yii_app\records\MarketplacePriority;
 use yii_app\records\MarketplaceStore;
+use yii_app\records\MatrixErp;
 use yii_app\records\MatrixErpMedia;
 use yii_app\records\MatrixErpProperty;
 use yii_app\records\Prices;
@@ -420,8 +421,24 @@ class MarketplaceService
 
         $productQuantities = $storeData[$storeGuid];
 
+        // Сначала получаем активные товары из MatrixErp с is_feed_active = 1
+        $activeMatrixProducts = MatrixErp::find()
+            ->where(['group_name' => 'marketplace'])
+            ->andWhere(['active' => 1])
+            ->andWhere(['is_feed_active' => 1])
+            ->all();
+
+        // Извлекаем GUID'ы активных товаров
+        $activeProductGuids = array_map(function($matrixProduct) {
+            return $matrixProduct->guid;
+        }, $activeMatrixProducts);
+
+        // Находим товары в Products1c только по активным GUID'ам из MatrixErp
+        // и которые есть на складе
+        $availableProductGuids = array_intersect($activeProductGuids, array_keys($productQuantities));
+
         $products = Products1c::find()
-            ->where(['id' => array_keys($productQuantities)])
+            ->where(['id' => $availableProductGuids])
             ->andWhere(['!=', 'components', ''])
             ->all();