From: fomichev Date: Fri, 25 Oct 2024 09:20:36 +0000 (+0300) Subject: Имитация фидов X-Git-Tag: 1.6~13^2~30 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c42cbfa93f07dda41dff2055d3823513564fa440;p=erp24_rep%2Fyii-erp24%2F.git Имитация фидов --- 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 = [];