From 0b11bad72a79429c7a972787505438faeb384731 Mon Sep 17 00:00:00 2001 From: Ivan Chaplygin Date: Fri, 1 Sep 2023 10:39:37 +0300 Subject: [PATCH] ref #90476 Implemented transfer of features to ICML catalog --- retailcrm/lib/RetailcrmCatalog.php | 2 +- retailcrm/lib/RetailcrmIcml.php | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) mode change 100644 => 100755 retailcrm/lib/RetailcrmIcml.php diff --git a/retailcrm/lib/RetailcrmCatalog.php b/retailcrm/lib/RetailcrmCatalog.php index c0f12e9..bf2178f 100755 --- a/retailcrm/lib/RetailcrmCatalog.php +++ b/retailcrm/lib/RetailcrmCatalog.php @@ -208,7 +208,7 @@ class RetailcrmCatalog } $offers = Product::getProductAttributesIds($product['id_product']); - $features = Product::getFeaturesStatic($product['id_product']); + $features = Product::getFrontFeaturesStatic($id_lang, $product['id_product']); if (!empty($offers)) { $offersCount += count($offers); diff --git a/retailcrm/lib/RetailcrmIcml.php b/retailcrm/lib/RetailcrmIcml.php old mode 100644 new mode 100755 index c15b8af..dbd3760 --- a/retailcrm/lib/RetailcrmIcml.php +++ b/retailcrm/lib/RetailcrmIcml.php @@ -189,6 +189,7 @@ class RetailcrmIcml $this->setOffersProperties($offer); $this->setOffersParams($offer); $this->setOffersCombinations($offer); + $this->setOffersFeatures($offer); $this->writer->endElement(); // end } @@ -213,7 +214,6 @@ class RetailcrmIcml private function setOffersParams($offer) { - RetailcrmLogger::writeCaller('inventories', print_r($offer, true)); foreach ($offer as $key => $value) { if (!array_key_exists($key, $this->params)) { continue; @@ -251,6 +251,25 @@ class RetailcrmIcml } } + private function setOffersFeatures($offer) + { + foreach ($offer['features'] as $feature) { + if ( + empty($feature['id_feature']) + || empty($feature['name']) + || $feature['value'] === null + ) { + continue; + } + + $this->writer->startElement('param'); + $this->writer->writeAttribute('code', 'feature_' . $feature['id_feature']); + $this->writer->writeAttribute('name' , $feature['name']); + $this->writer->text($feature['value']); + $this->writer->endElement(); + } + } + private function writeEnd() { $this->writer->endElement(); // end