diff --git a/CHANGELOG.md b/CHANGELOG.md index 65a57bc2..6714a138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-06-04 v.6.5.17 +- Добавлена передача признака маркировки товара в ICML каталоге + ## 2024-04-27 v.6.5.16 - Обновлены аннотации в коде модуля diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 60942447..03326223 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Обновлены аннотации в коде модуля +- Добавлена передача признака маркировки товара в ICML каталоге diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 54c62891..860b00ff 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.5.16', - 'VERSION_DATE' => '2024-04-27 14:00:00' + 'VERSION' => '6.5.17', + 'VERSION_DATE' => '2024-06-04 12:00:00' ]; diff --git a/intaro.retailcrm/lib/icml/icmlwriter.php b/intaro.retailcrm/lib/icml/icmlwriter.php index 6db3d810..07e72eac 100644 --- a/intaro.retailcrm/lib/icml/icmlwriter.php +++ b/intaro.retailcrm/lib/icml/icmlwriter.php @@ -157,6 +157,7 @@ class IcmlWriter $this->writeSimpleElement('name', $offer->name); $this->writeSimpleElement('productName', $offer->productName); $this->writeSimpleElement('xmlId', $offer->xmlId); + $this->writeSimpleElement('markable', $offer->markable); $this->writeOptionalSimpleElement('vendor', $offer->vendor); $this->writeOptionalSimpleElement('barcode', $offer->barcode); $this->writeOptionalSimpleElement('vatRate', $offer->vatRate); diff --git a/intaro.retailcrm/lib/icml/xmlofferbuilder.php b/intaro.retailcrm/lib/icml/xmlofferbuilder.php index 6bce17dc..e12eed3a 100644 --- a/intaro.retailcrm/lib/icml/xmlofferbuilder.php +++ b/intaro.retailcrm/lib/icml/xmlofferbuilder.php @@ -3,8 +3,12 @@ namespace Intaro\RetailCrm\Icml; use Bitrix\Catalog\ProductTable; +use Bitrix\Highloadblock\HighloadBlockTable; +use Bitrix\Iblock; use Bitrix\Main\ArgumentException; -use Intaro\RetailCrm\Component\ServiceLocator; +use Bitrix\Main\Entity; +use Bitrix\Main\Loader; +use Bitrix\Main\UserField\Internal\UserFieldHelper; use Intaro\RetailCrm\Icml\Utils\IcmlUtils; use Intaro\RetailCrm\Model\Bitrix\Orm\CatalogIblockInfo; use Intaro\RetailCrm\Model\Bitrix\Xml\OfferParam; @@ -116,6 +120,10 @@ class XmlOfferBuilder $this->vatRates = $this->settingsService->vatRates; $this->measures = $this->prepareMeasures($measure); $this->serverName = $serverName; + + Loader::includeModule("highloadblock"); + Loader::includeModule('iblock'); + Loader::includeModule('catalog'); } /** @@ -262,6 +270,7 @@ class XmlOfferBuilder $this->xmlOffer->vatRate = $this->getVatRate($item); $this->xmlOffer->unitCode = $this->getUnitCode($item['CATALOG_MEASURE'], $item['ID']); $this->xmlOffer->activity = $item['ACTIVE']; + $this->xmlOffer->markable = $this->isMarkableOffer($item['ID']); } /** @@ -565,4 +574,31 @@ class XmlOfferBuilder return null; } + + /** + * Метод для проверки можно ли маркировать товар. + * + * Таблица в БД - b_hlsys_marking_code_group + * По умолчанию ID Highload-блока ProductMarkingCodeGroup - 1. + * + * @param $offerId + * @return void + */ + private function isMarkableOffer($offerId): ?string + { + $idHlBlock = 1; + $hlBlock = HighloadBlockTable::getById($idHlBlock)->fetch(); + $hlBlockData = HighloadBlockTable::compileEntity($hlBlock)->getDataClass(); + $userFieldManager = UserFieldHelper::getInstance()->getManager(); + $userFieldsData = $userFieldManager->GetUserFields(ProductTable::getUfId(), $offerId); + $ufProductGroup = $userFieldsData['UF_PRODUCT_GROUP']['VALUE'] ?? null; + $isMarkableOffer = null; + + if ($ufProductGroup !== null) { + $productGroup = $hlBlockData::getList(["select" => ["UF_NAME"], "filter" => ['ID' => $ufProductGroup]]); + $isMarkableOffer = !empty($productGroup->Fetch()['UF_NAME']) ? 'Y' : 'N'; + } + + return $isMarkableOffer; + } } diff --git a/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php b/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php index 9b10ae98..a4e54964 100644 --- a/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php +++ b/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php @@ -140,6 +140,8 @@ class XmlOffer */ public ?string $activityProduct = null; + public ?string $markable = null; + /** * @param $productValue * @param $offerValue