1
0
mirror of synced 2024-11-23 22:06:11 +03:00

ref #73933 Добавлена передача признака маркировки товара в ICML каталоге (#348)

This commit is contained in:
Uryvskiy Dima 2024-06-04 12:05:51 +03:00 committed by GitHub
parent 453bc495c0
commit ee6d654d8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 46 additions and 4 deletions

View File

@ -1,3 +1,6 @@
## 2024-06-04 v.6.5.17
- Добавлена передача признака маркировки товара в ICML каталоге
## 2024-04-27 v.6.5.16
- Обновлены аннотации в коде модуля

View File

@ -1 +1 @@
- Обновлены аннотации в коде модуля
- Добавлена передача признака маркировки товара в ICML каталоге

View File

@ -1,6 +1,6 @@
<?php
$arModuleVersion = [
'VERSION' => '6.5.16',
'VERSION_DATE' => '2024-04-27 14:00:00'
'VERSION' => '6.5.17',
'VERSION_DATE' => '2024-06-04 12:00:00'
];

View File

@ -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);

View File

@ -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;
}
}

View File

@ -140,6 +140,8 @@ class XmlOffer
*/
public ?string $activityProduct = null;
public ?string $markable = null;
/**
* @param $productValue
* @param $offerValue