Skip to content

Commit

Permalink
ref #73933 Добавлена передача признака маркировки товара в ICML катал…
Browse files Browse the repository at this point in the history
…оге (#348)
  • Loading branch information
uryvskiy-dima committed Jun 4, 2024
1 parent 453bc49 commit ee6d654
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2024-06-04 v.6.5.17
- Добавлена передача признака маркировки товара в ICML каталоге

## 2024-04-27 v.6.5.16
- Обновлены аннотации в коде модуля

Expand Down
2 changes: 1 addition & 1 deletion intaro.retailcrm/description.ru
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Обновлены аннотации в коде модуля
- Добавлена передача признака маркировки товара в ICML каталоге
4 changes: 2 additions & 2 deletions intaro.retailcrm/install/version.php
Original file line number Diff line number Diff line change
@@ -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'
];
1 change: 1 addition & 0 deletions intaro.retailcrm/lib/icml/icmlwriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ private function writeOffer(XmlOffer $offer): void
$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);
Expand Down
38 changes: 37 additions & 1 deletion intaro.retailcrm/lib/icml/xmlofferbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,6 +120,10 @@ public function __construct(XmlSetup $setup, array $measure, ?string $serverName
$this->vatRates = $this->settingsService->vatRates;
$this->measures = $this->prepareMeasures($measure);
$this->serverName = $serverName;

Loader::includeModule("highloadblock");
Loader::includeModule('iblock');
Loader::includeModule('catalog');
}

/**
Expand Down Expand Up @@ -262,6 +270,7 @@ private function addDataFromItem(array $item, array $categoryIds): void
$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']);
}

/**
Expand Down Expand Up @@ -565,4 +574,31 @@ private function getUnitCode(?int $measureId, int $itemId): ?Unit

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;
}
}
2 changes: 2 additions & 0 deletions intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class XmlOffer
*/
public ?string $activityProduct = null;

public ?string $markable = null;

/**
* @param $productValue
* @param $offerValue
Expand Down

0 comments on commit ee6d654

Please sign in to comment.