parent
c1f59ead7f
commit
1eabbe323b
@ -1,3 +1,6 @@
|
||||
## 2024-04-23 v.6.5.15
|
||||
- Добавлена передача услуг через ICML каталог
|
||||
|
||||
## 2024-04-18 v.6.5.14
|
||||
- Исправление работы кнопки "Выгрузка служб доставок"
|
||||
|
||||
|
@ -1 +1 @@
|
||||
- Исправление работы кнопки "Выгрузка служб доставок"
|
||||
- Добавлена передача услуг через ICML каталог
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.5.14',
|
||||
'VERSION_DATE' => '2024-04-18 11:15:00'
|
||||
'VERSION' => '6.5.15',
|
||||
'VERSION_DATE' => '2024-04-23 10:30:00'
|
||||
];
|
||||
|
@ -46,3 +46,4 @@ $MESS["UNIT_MEASUREMENT_KG"] = "kg";
|
||||
$MESS['BASE_PRICE'] = 'Base price';
|
||||
$MESS['WAIT'] = 'Loading...';
|
||||
$MESS["OFFERS_VALUE"] = "Maximum number of trade offers for a product";
|
||||
$MESS["LOAD_NON_ACTIVITY"] = "Unload inactive products, services and trade offers";
|
||||
|
@ -7,7 +7,7 @@ $MESS["CATALOG"] = "Каталог";
|
||||
$MESS["EXPORT2INTAROCML"] = "Выгрузить в ICML";
|
||||
$MESS["FILENAME"] = "Укажите имя файла данных:";
|
||||
$MESS["LOAD_PURCHASE_PRICE"] = "Выгружать закупочную цену";
|
||||
$MESS["LOAD_NON_ACTIVITY"] = "Выгружать неактивные товары и торговые предложения";
|
||||
$MESS["LOAD_NON_ACTIVITY"] = "Выгружать неактивные товары, услуги и торговые предложения";
|
||||
$MESS["PROPERTY"] = "Свойство, содержащее артикул товара";
|
||||
$MESS["ALL_CATALOG"] = "Все каталоги";
|
||||
$MESS["EXPORT"] = "Экспортировать";
|
||||
|
@ -78,13 +78,15 @@ class IcmlDirector
|
||||
{
|
||||
$this->setup = $setup;
|
||||
$this->shopName = RetailcrmConfigProvider::getSiteName();
|
||||
$this->catalogRepository = new CatalogRepository();
|
||||
$this->icmlWriter = new IcmlWriter($this->setup->filePath);
|
||||
$this->xmlOfferDirector = new XmlOfferDirector($this->setup);
|
||||
$this->xmlCategoryDirector = new XmlCategoryDirector($this->setup->iblocksForExport);
|
||||
$this->xmlCategoryDirector = new XmlCategoryDirector($this->setup);
|
||||
$this->queryBuilder = new QueryParamsMolder();
|
||||
$this->xmlData = new XmlData();
|
||||
$this->logger = $logger;
|
||||
$this->catalogRepository = new CatalogRepository();
|
||||
|
||||
$this->catalogRepository->setLoadNotActive($this->setup->loadNonActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +166,7 @@ class IcmlDirector
|
||||
$selectParams->allParams = array_merge($selectParams->configurable, $selectParams->main);
|
||||
|
||||
while ($xmlOffers = $this->xmlOfferDirector->getXmlOffersPart($selectParams, $catalogIblockInfo)) {
|
||||
$this->icmlWriter->writeOffers($xmlOffers, $xmlOffers->activity === 'N');
|
||||
$this->icmlWriter->writeOffers($xmlOffers);
|
||||
$selectParams->pageNumber++;
|
||||
}
|
||||
|
||||
@ -249,15 +251,9 @@ class IcmlDirector
|
||||
$paramsForOffer->allParams = array_merge($paramsForOffer->configurable, $paramsForOffer->main);
|
||||
|
||||
do {
|
||||
$isNotActiveProduct = false;
|
||||
|
||||
if ($product->activity === 'N') {
|
||||
$isNotActiveProduct = true;
|
||||
}
|
||||
|
||||
//Если каталог проиндексирован, у товара есть Тип и это простой товар, то просто записываем его
|
||||
if ($product->productType === ProductTable::TYPE_PRODUCT) {
|
||||
$this->icmlWriter->writeOffers([$product], $isNotActiveProduct);
|
||||
$this->icmlWriter->writeOffers([$product]);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -266,7 +262,7 @@ class IcmlDirector
|
||||
|
||||
// если это "простой товар", у которого нет ТП, то просто записываем его
|
||||
if ($paramsForOffer->pageNumber === 1 && count($xmlOffersPart) === 0) {
|
||||
$this->icmlWriter->writeOffers([$product], $isNotActiveProduct);
|
||||
$this->icmlWriter->writeOffers([$product]);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -274,7 +270,7 @@ class IcmlDirector
|
||||
$xmlOffersPart
|
||||
= $this->trimOffersList($writingOffersCount, $xmlOffersPart);
|
||||
|
||||
$this->icmlWriter->writeOffers($xmlOffersPart, $isNotActiveProduct);
|
||||
$this->icmlWriter->writeOffers($xmlOffersPart);
|
||||
|
||||
$writingOffersCount += count($xmlOffersPart);
|
||||
$paramsForOffer->pageNumber++;
|
||||
|
@ -7,6 +7,7 @@ use Intaro\RetailCrm\Model\Bitrix\Xml\XmlCategory;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlData;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlOffer;
|
||||
use XMLWriter;
|
||||
use Bitrix\Catalog\ProductTable;
|
||||
|
||||
/**
|
||||
* Отвечает за запись данных каталога в файл
|
||||
@ -23,6 +24,7 @@ class IcmlWriter
|
||||
* @var \XMLWriter
|
||||
*/
|
||||
private $writer;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -99,10 +101,10 @@ class IcmlWriter
|
||||
* @param XmlOffer[] $offers
|
||||
* @param bool $isNotActiveProduct
|
||||
*/
|
||||
public function writeOffers(array $offers, $isNotActiveProduct = false): void
|
||||
public function writeOffers(array $offers): void
|
||||
{
|
||||
foreach ($offers as $offer) {
|
||||
$this->writeOffer($offer, $isNotActiveProduct);
|
||||
$this->writeOffer($offer);
|
||||
}
|
||||
|
||||
file_put_contents($this->filePath, $this->writer->flush(true), FILE_APPEND);
|
||||
@ -112,19 +114,16 @@ class IcmlWriter
|
||||
* @param \Intaro\RetailCrm\Model\Bitrix\Xml\XmlOffer $offer
|
||||
* @param bool $isNotActiveProduct
|
||||
*/
|
||||
private function writeOffer(XmlOffer $offer, $isNotActiveProduct): void
|
||||
private function writeOffer(XmlOffer $offer): void
|
||||
{
|
||||
$productType = $offer->productType === ProductTable::TYPE_SERVICE ? 'service' : 'product';
|
||||
|
||||
$this->writer->startElement('offer');
|
||||
$this->writeSimpleAttribute('id', $offer->id);
|
||||
$this->writeSimpleAttribute('type', $productType);
|
||||
$this->writeSimpleAttribute('productId', $offer->productId);
|
||||
$this->writeSimpleAttribute('quantity', $offer->quantity);
|
||||
|
||||
if ($isNotActiveProduct) {
|
||||
$this->writeSimpleElement('productActivity', 'N');
|
||||
} else {
|
||||
$this->writeSimpleElement('activity', $offer->activity);
|
||||
}
|
||||
|
||||
foreach ($offer->categoryIds as $categoryId) {
|
||||
$this->writeSimpleElement('categoryId', $categoryId);
|
||||
}
|
||||
@ -145,6 +144,14 @@ class IcmlWriter
|
||||
$this->writeParam($param);
|
||||
}
|
||||
|
||||
$activity = $offer->activity;
|
||||
|
||||
null === $offer->activityProduct ?
|
||||
$this->writeSimpleElement('productActivity', $activity) :
|
||||
$this->writeSimpleElement('productActivity', $offer->activityProduct)
|
||||
;
|
||||
|
||||
$this->writeSimpleElement('activity', $activity);
|
||||
$this->writeSimpleElement('url', $offer->url);
|
||||
$this->writeSimpleElement('price', $offer->price);
|
||||
$this->writeSimpleElement('name', $offer->name);
|
||||
|
@ -8,6 +8,7 @@ use Bitrix\Main\ORM\Objectify\Collection;
|
||||
use Bitrix\Main\ORM\Objectify\EntityObject;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlCategory;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetup;
|
||||
use Intaro\RetailCrm\Repository\CatalogRepository;
|
||||
use Intaro\RetailCrm\Repository\FileRepository;
|
||||
use Intaro\RetailCrm\Repository\SiteRepository;
|
||||
@ -40,12 +41,14 @@ class XmlCategoryDirector
|
||||
*/
|
||||
private $fileRepository;
|
||||
|
||||
public function __construct(array $iblocksForExport)
|
||||
public function __construct(XmlSetup $setup)
|
||||
{
|
||||
$this->iblocksForExport = $iblocksForExport;
|
||||
$this->catalogRepository = new CatalogRepository();
|
||||
$this->iblocksForExport = $setup->iblocksForExport;
|
||||
$this->xmlCategoryFactory = new XmlCategoryFactory();
|
||||
$this->fileRepository = new FileRepository(SiteRepository::getDefaultServerName());
|
||||
$this->catalogRepository = new CatalogRepository();
|
||||
|
||||
$this->catalogRepository->setLoadNotActive($setup->loadNonActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,12 +53,14 @@ class XmlOfferDirector
|
||||
{
|
||||
$this->setup = $setup;
|
||||
$this->fileRepository = new FileRepository(SiteRepository::getDefaultServerName());
|
||||
$this->catalogRepository = new CatalogRepository();
|
||||
$this->xmlOfferBuilder = new XmlOfferBuilder(
|
||||
$setup,
|
||||
MeasureRepository::getMeasures(),
|
||||
SiteRepository::getDefaultServerName()
|
||||
);
|
||||
$this->catalogRepository = new CatalogRepository();
|
||||
|
||||
$this->catalogRepository->setLoadNotActive($this->setup->loadNonActivity);
|
||||
$this->barcodes = $this->catalogRepository->getBarcodes();
|
||||
}
|
||||
|
||||
@ -71,7 +73,7 @@ class XmlOfferDirector
|
||||
*/
|
||||
public function getXmlOffersPart(SelectParams $param, CatalogIblockInfo $catalogIblockInfo): array
|
||||
{
|
||||
$ciBlockResult = $this->catalogRepository->getProductPage($param, $catalogIblockInfo, $this->setup->loadNonActivity);
|
||||
$ciBlockResult = $this->catalogRepository->getProductPage($param, $catalogIblockInfo);
|
||||
$offers = [];
|
||||
|
||||
$this->xmlOfferBuilder->setServerName($this->fileRepository->getServerName($catalogIblockInfo->productIblockId));
|
||||
@ -130,6 +132,7 @@ class XmlOfferDirector
|
||||
$offer->categoryIds = $product->categoryIds;
|
||||
$offer->productName = $product->productName;
|
||||
$offer->url = $this->mergeUrls($product->url, $offer->url);
|
||||
$offer->activityProduct = $product->activity;
|
||||
}
|
||||
|
||||
return $xmlOffers;
|
||||
|
@ -28,7 +28,7 @@ class XmlOffer
|
||||
public $productId;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var string
|
||||
*/
|
||||
public $quantity;
|
||||
|
||||
@ -136,6 +136,12 @@ class XmlOffer
|
||||
*/
|
||||
public $activity;
|
||||
|
||||
/**
|
||||
* Признак активности товара при наличии торговых предложений
|
||||
* @var string | null
|
||||
*/
|
||||
public ?string $activityProduct = null;
|
||||
|
||||
/**
|
||||
* @param $productValue
|
||||
* @param $offerValue
|
||||
|
@ -31,6 +31,11 @@ class CatalogRepository
|
||||
*/
|
||||
private $builder;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isLoadNotActive = false;
|
||||
|
||||
/**
|
||||
* CatalogRepository constructor.
|
||||
*/
|
||||
@ -39,6 +44,11 @@ class CatalogRepository
|
||||
$this->builder = new QueryParamsMolder();
|
||||
}
|
||||
|
||||
public function setLoadNotActive(bool $isLoad)
|
||||
{
|
||||
$this->isLoadNotActive = $isLoad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение категорий, к которым относится товар
|
||||
*
|
||||
@ -88,14 +98,13 @@ class CatalogRepository
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Bitrix\Xml\SelectParams $param
|
||||
* @param \Intaro\RetailCrm\Model\Bitrix\Orm\CatalogIblockInfo $catalogIblockInfo
|
||||
* @param boolean $loadNonActivity
|
||||
* @return \CIBlockResult|int
|
||||
*/
|
||||
public function getProductPage(SelectParams $param, CatalogIblockInfo $catalogIblockInfo, bool $loadNonActivity)
|
||||
public function getProductPage(SelectParams $param, CatalogIblockInfo $catalogIblockInfo)
|
||||
{
|
||||
return CIBlockElement::GetList(
|
||||
['ID' => 'ASC'],
|
||||
$this->builder->getWhereForOfferPart($param->parentId, $catalogIblockInfo, $loadNonActivity),
|
||||
$this->builder->getWhereForOfferPart($param->parentId, $catalogIblockInfo, $this->isLoadNotActive),
|
||||
false,
|
||||
['nPageSize' => $param->nPageSize, 'iNumPage' => $param->pageNumber, 'checkOutOfRange' => true],
|
||||
$param->allParams
|
||||
|
Loading…
Reference in New Issue
Block a user