From 78316bd4c7ec10b64954362c174d6a10f6c15427 Mon Sep 17 00:00:00 2001 From: gleemand Date: Mon, 18 Oct 2021 17:52:16 +0300 Subject: [PATCH] Added combination attributes to ICML --- retailcrm/lib/RetailcrmCatalog.php | 10 ++++++++-- retailcrm/lib/RetailcrmIcml.php | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/retailcrm/lib/RetailcrmCatalog.php b/retailcrm/lib/RetailcrmCatalog.php index 9eebbb5..b5e2e6a 100644 --- a/retailcrm/lib/RetailcrmCatalog.php +++ b/retailcrm/lib/RetailcrmCatalog.php @@ -221,7 +221,8 @@ class RetailcrmCatalog foreach ($combinations as $combination) { $arSet = [ 'group_name' => $combination['group_name'], - 'attribute' => $combination['attribute_name'], + 'id_attribute_group' => $combination['id_attribute_group'], + 'attribute_name' => $combination['attribute_name'], ]; $arComb[] = $arSet; @@ -285,10 +286,15 @@ class RetailcrmCatalog if (!empty($combinations)) { foreach ($arComb as $itemComb) { - $item[mb_strtolower($itemComb['group_name'])] = htmlspecialchars($itemComb['attribute']); + $item['combination'][$itemComb['id_attribute_group']] = [ + 'group_name' => mb_strtolower($itemComb['group_name']), + 'attribute_name' => htmlspecialchars($itemComb['attribute_name']), + ]; } } + unset($arComb); + yield RetailcrmTools::filter( 'RetailcrmFilterProcessOffer', $item, diff --git a/retailcrm/lib/RetailcrmIcml.php b/retailcrm/lib/RetailcrmIcml.php index 0313609..a198e5e 100644 --- a/retailcrm/lib/RetailcrmIcml.php +++ b/retailcrm/lib/RetailcrmIcml.php @@ -182,6 +182,18 @@ class RetailcrmIcml $e->appendChild($param); } } + + if (isset($offer['combination'])) { + foreach ($offer['combination'] as $id => $comb) { + $param = $this->dd->createElement('param'); + $param->setAttribute('code', $id); + $param->setAttribute('name', $comb['group_name']); + $param->appendChild( + $this->dd->createTextNode($comb['attribute_name']) + ); + $e->appendChild($param); + } + } } } }