From c42cbfa93f07dda41dff2055d3823513564fa440 Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 25 Oct 2024 12:20:36 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D0=BC=D0=B8=D1=82=D0=B0=D1=86=D0=B8=D1=8F?= =?utf8?q?=20=D1=84=D0=B8=D0=B4=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/FlowwowController.php | 4 ++-- erp24/services/MarketplaceService.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/erp24/api2/controllers/FlowwowController.php b/erp24/api2/controllers/FlowwowController.php index 91736e78..a2fb0706 100644 --- a/erp24/api2/controllers/FlowwowController.php +++ b/erp24/api2/controllers/FlowwowController.php @@ -15,8 +15,8 @@ class FlowwowController extends Controller public function actionFeed($id) { // Получаем информацию о продуктах - // $productsInfo = MarketplaceService::getAllProductsInfo(); - $productsInfo = MarketplaceService::getSomeProductsInfo(3); + $productsInfo = MarketplaceService::getAllProductsInfo($id); + // $productsInfo = MarketplaceService::getSomeProductsInfo(3); // Генерируем XML-фид $xmlFeed = MarketplaceService::createXMLFeed($productsInfo); diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index 44316f7d..935e9485 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -13,13 +13,13 @@ class MarketplaceService * * @return array */ - public static function getAllProductsInfo() + public static function getAllProductsInfo($id) { - + // Получаем category_id для типа 'marketplace' $parents = ProductsClass::find() ->select('category_id') ->where(['tip' => 'marketplace']) - ->one(); + ->column(); $products = Products1c::find() @@ -28,9 +28,13 @@ class MarketplaceService ->andWhere(['parent_id' => $parents]) ->all(); + + $count = (int)$id; + $selectedProducts = array_slice($products, 0, $count); + $result = []; - foreach ($products as $product) { + foreach ($selectedProducts as $product) { $components = json_decode($product->components, true); $composition = []; -- 2.39.5