From ee6d654d8c858ead5149e91ca9032ed791e5a1d2 Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Tue, 4 Jun 2024 12:05:51 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#73933=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=20=D0=BF=D1=80=D0=B8=D0=B7=D0=BD=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BC=D0=B0=D1=80=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=B0=20=D0=B2=20ICML=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B0=D0=BB=D0=BE=D0=B3=D0=B5=20(#348)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +- intaro.retailcrm/lib/icml/icmlwriter.php | 1 + intaro.retailcrm/lib/icml/xmlofferbuilder.php | 38 ++++++++++++++++++- .../lib/model/bitrix/xml/xmloffer.php | 2 + 6 files changed, 46 insertions(+), 4 deletions(-) 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