diff --git a/CHANGELOG.md b/CHANGELOG.md index d0d8a4bf..5dac417f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-04-10 v.6.3.2 +- Добавлена возможность экспорта неактивных товаров и торговых предложений + ## 2023-04-10 v.6.3.1 - Добавлена валидация свойств товаров и торговых предложений в настройках экспорта diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index a8328f44..ba6f30bc 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Добавлена валидация свойств товаров и торговых предложений в настройках экспорта +- Добавлена возможность экспорта неактивных товаров и торговых предложений diff --git a/intaro.retailcrm/export/export_run.php b/intaro.retailcrm/export/export_run.php index 903e42c9..4449c336 100644 --- a/intaro.retailcrm/export/export_run.php +++ b/intaro.retailcrm/export/export_run.php @@ -159,6 +159,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp $fileSetup->maxOffersValue = $maxOffersValue ?? null; $fileSetup->filePath = $SETUP_FILE_NAME; $fileSetup->loadPurchasePrice = $loadPurchasePrice === 'Y'; + $fileSetup->loadNonActivity = $loadNonActivity === 'Y'; $fileSetup->basePriceId = CatalogRepository::getBasePriceId($fileSetup->profileId); if (!is_array($fileSetup->iblocksForExport) || count($fileSetup->iblocksForExport) === 0) { diff --git a/intaro.retailcrm/export/export_setup.php b/intaro.retailcrm/export/export_setup.php index 9ecbf239..cab702bc 100644 --- a/intaro.retailcrm/export/export_setup.php +++ b/intaro.retailcrm/export/export_setup.php @@ -66,6 +66,7 @@ if (($ACTION === 'EXPORT' || $ACTION === 'EXPORT_EDIT' || $ACTION === 'EXPORT_CO $iblockProperties = $settingsService->getIblockPropsPreset(); $loadPurchasePrice = $settingsService->loadPurchasePrice; $iblockExport = $settingsService->iblockExport; + $loadNonActivity = $settingsService->loadNonActivity; if ($iblockExport) { $maxOffersValue = $settingsService->getSingleSetting('maxOffersValue'); @@ -491,6 +492,9 @@ if ($STEP === 1) { $SETUP_FILE_NAME : $settingsService->setupFileName); ?>" size="50">

  > +
+   + >


diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 17653d7d..5be0e379 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.3.1', - 'VERSION_DATE' => '2023-04-10 10:00:00' + 'VERSION' => '6.3.2', + 'VERSION_DATE' => '2023-04-10 18:00:00' ]; diff --git a/intaro.retailcrm/lang/ru/icml_export_setup.php b/intaro.retailcrm/lang/ru/icml_export_setup.php index a1c66d57..703c893b 100644 --- a/intaro.retailcrm/lang/ru/icml_export_setup.php +++ b/intaro.retailcrm/lang/ru/icml_export_setup.php @@ -7,6 +7,7 @@ $MESS["CATALOG"] = "Каталог"; $MESS["EXPORT2INTAROCML"] = "Выгрузить в ICML"; $MESS["FILENAME"] = "Укажите имя файла данных:"; $MESS["LOAD_PURCHASE_PRICE"] = "Выгружать закупочную цену"; +$MESS["LOAD_NON_ACTIVITY"] = "Выгружать неактивные товары и торговые предложения"; $MESS["PROPERTY"] = "Свойство, содержащее артикул товара"; $MESS["ALL_CATALOG"] = "Все каталоги"; $MESS["EXPORT"] = "Экспортировать"; diff --git a/intaro.retailcrm/lib/icml/icmldirector.php b/intaro.retailcrm/lib/icml/icmldirector.php index 384a0437..8ded832f 100644 --- a/intaro.retailcrm/lib/icml/icmldirector.php +++ b/intaro.retailcrm/lib/icml/icmldirector.php @@ -164,8 +164,7 @@ class IcmlDirector $selectParams->allParams = array_merge($selectParams->configurable, $selectParams->main); while ($xmlOffers = $this->xmlOfferDirector->getXmlOffersPart($selectParams, $catalogIblockInfo)) { - $this->icmlWriter->writeOffers($xmlOffers); - + $this->icmlWriter->writeOffers($xmlOffers, $xmlOffers->activity === 'N'); $selectParams->pageNumber++; } @@ -250,9 +249,15 @@ 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]); + $this->icmlWriter->writeOffers([$product], $isNotActiveProduct); break; } @@ -261,7 +266,7 @@ class IcmlDirector // если это "простой товар", у которого нет ТП, то просто записываем его if ($paramsForOffer->pageNumber === 1 && count($xmlOffersPart) === 0) { - $this->icmlWriter->writeOffers([$product]); + $this->icmlWriter->writeOffers([$product], $isNotActiveProduct); break; } @@ -269,7 +274,7 @@ class IcmlDirector $xmlOffersPart = $this->trimOffersList($writingOffersCount, $xmlOffersPart); - $this->icmlWriter->writeOffers($xmlOffersPart); + $this->icmlWriter->writeOffers($xmlOffersPart, $isNotActiveProduct); $writingOffersCount += count($xmlOffersPart); $paramsForOffer->pageNumber++; diff --git a/intaro.retailcrm/lib/icml/icmlwriter.php b/intaro.retailcrm/lib/icml/icmlwriter.php index a9688f1b..3bee9e82 100644 --- a/intaro.retailcrm/lib/icml/icmlwriter.php +++ b/intaro.retailcrm/lib/icml/icmlwriter.php @@ -97,11 +97,12 @@ class IcmlWriter /** * @param XmlOffer[] $offers + * @param bool $isNotActiveProduct */ - public function writeOffers(array $offers): void + public function writeOffers(array $offers, $isNotActiveProduct = false): void { foreach ($offers as $offer) { - $this->writeOffer($offer); + $this->writeOffer($offer, $isNotActiveProduct); } file_put_contents($this->filePath, $this->writer->flush(true), FILE_APPEND); @@ -109,14 +110,21 @@ class IcmlWriter /** * @param \Intaro\RetailCrm\Model\Bitrix\Xml\XmlOffer $offer + * @param bool $isNotActiveProduct */ - private function writeOffer(XmlOffer $offer): void + private function writeOffer(XmlOffer $offer, $isNotActiveProduct): void { $this->writer->startElement('offer'); $this->writeSimpleAttribute('id', $offer->id); $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); } diff --git a/intaro.retailcrm/lib/icml/queryparamsmolder.php b/intaro.retailcrm/lib/icml/queryparamsmolder.php index 5bb952f3..c9917fba 100644 --- a/intaro.retailcrm/lib/icml/queryparamsmolder.php +++ b/intaro.retailcrm/lib/icml/queryparamsmolder.php @@ -58,6 +58,7 @@ class QueryParamsMolder 'ID', 'LID', 'VAT_ID', + 'ACTIVE' ]; return $params; @@ -66,20 +67,27 @@ class QueryParamsMolder /** * @param int|null $parentId * @param \Intaro\RetailCrm\Model\Bitrix\Orm\CatalogIblockInfo $info + * @param boolean $loadNonActivity * @return array */ - public function getWhereForOfferPart(?int $parentId, CatalogIblockInfo $info): array + public function getWhereForOfferPart(?int $parentId, CatalogIblockInfo $info, bool $loadNonActivity): array { + $active = ""; + + if (!$loadNonActivity) { + $active = "Y"; + } + if ($parentId === null) { return [ 'IBLOCK_ID' => $info->productIblockId, - 'ACTIVE' => 'Y', + 'ACTIVE' => $active, ]; } return [ 'IBLOCK_ID' => $info->skuIblockId, - 'ACTIVE' => 'Y', + 'ACTIVE' => $active, 'PROPERTY_' . $info->skuPropertyId => $parentId, ]; } diff --git a/intaro.retailcrm/lib/icml/settingsservice.php b/intaro.retailcrm/lib/icml/settingsservice.php index 12c585b8..1369950c 100644 --- a/intaro.retailcrm/lib/icml/settingsservice.php +++ b/intaro.retailcrm/lib/icml/settingsservice.php @@ -92,6 +92,11 @@ class SettingsService */ public $vatRates = []; + /** + * @var mixed|string|null + */ + public $loadNonActivity; + /** * @var \Intaro\RetailCrm\Icml\SettingsService|null */ @@ -109,6 +114,7 @@ class SettingsService $this->action = $action; $this->iblockExport = $this->getSingleSetting('iblockExport'); $this->loadPurchasePrice = $this->getSingleSetting('loadPurchasePrice'); + $this->loadNonActivity = $this->getSingleSetting('loadNonActivity'); $oldSetup = $this->getSingleSetting('SETUP_FILE_NAME'); $defaultFilePath = RetailcrmConfigProvider::getDefaultIcmlPath(); $this->setupFileName = htmlspecialcharsbx($oldSetup ?? $defaultFilePath); @@ -419,7 +425,7 @@ class SettingsService */ public function getSetupFieldsString(array $iblockProperties, bool $hlblockModule, array $hlBlockList): string { - $values = 'loadPurchasePrice,SETUP_FILE_NAME,iblockExport,maxOffersValue'; + $values = 'loadPurchasePrice,SETUP_FILE_NAME,iblockExport,maxOffersValue,loadNonActivity'; foreach ($iblockProperties as $val) { $values .= ',iblockPropertySku_' . $val diff --git a/intaro.retailcrm/lib/icml/xmlofferbuilder.php b/intaro.retailcrm/lib/icml/xmlofferbuilder.php index 9955a210..5a789e71 100644 --- a/intaro.retailcrm/lib/icml/xmlofferbuilder.php +++ b/intaro.retailcrm/lib/icml/xmlofferbuilder.php @@ -252,6 +252,7 @@ class XmlOfferBuilder $this->xmlOffer->productName = $item['NAME']; $this->xmlOffer->vatRate = $this->getVatRate($item); $this->xmlOffer->unitCode = $this->getUnitCode($item['CATALOG_MEASURE'], $item['ID']); + $this->xmlOffer->activity = $item['ACTIVE']; } /** diff --git a/intaro.retailcrm/lib/icml/xmlofferdirector.php b/intaro.retailcrm/lib/icml/xmlofferdirector.php index 0baf2996..afca61e3 100644 --- a/intaro.retailcrm/lib/icml/xmlofferdirector.php +++ b/intaro.retailcrm/lib/icml/xmlofferdirector.php @@ -71,7 +71,7 @@ class XmlOfferDirector */ public function getXmlOffersPart(SelectParams $param, CatalogIblockInfo $catalogIblockInfo): array { - $ciBlockResult = $this->catalogRepository->getProductPage($param, $catalogIblockInfo); + $ciBlockResult = $this->catalogRepository->getProductPage($param, $catalogIblockInfo, $this->setup->loadNonActivity); $offers = []; while ($offer = $ciBlockResult->Fetch()) { diff --git a/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php b/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php index 1f37e13b..b1e312bd 100644 --- a/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php +++ b/intaro.retailcrm/lib/model/bitrix/xml/xmloffer.php @@ -129,6 +129,13 @@ class XmlOffer */ public $productType; + /** + * Активность товара/торгового предложения (N|Y) + * + * @var string + */ + public $activity; + /** * @param $productValue * @param $offerValue diff --git a/intaro.retailcrm/lib/model/bitrix/xml/xmlsetup.php b/intaro.retailcrm/lib/model/bitrix/xml/xmlsetup.php index 7b7a53f9..6bd2e40d 100644 --- a/intaro.retailcrm/lib/model/bitrix/xml/xmlsetup.php +++ b/intaro.retailcrm/lib/model/bitrix/xml/xmlsetup.php @@ -71,4 +71,10 @@ class XmlSetup * @var int|null */ public $basePriceId; + + /** + * + * @var bool + */ + public $loadNonActivity; } diff --git a/intaro.retailcrm/lib/repository/catalogrepository.php b/intaro.retailcrm/lib/repository/catalogrepository.php index 8a2a3411..0f7223f1 100644 --- a/intaro.retailcrm/lib/repository/catalogrepository.php +++ b/intaro.retailcrm/lib/repository/catalogrepository.php @@ -88,13 +88,14 @@ 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) + public function getProductPage(SelectParams $param, CatalogIblockInfo $catalogIblockInfo, bool $loadNonActivity) { return CIBlockElement::GetList( ['ID' => 'ASC'], - $this->builder->getWhereForOfferPart($param->parentId, $catalogIblockInfo), + $this->builder->getWhereForOfferPart($param->parentId, $catalogIblockInfo, $loadNonActivity), false, ['nPageSize' => $param->nPageSize, 'iNumPage' => $param->pageNumber, 'checkOutOfRange' => true], $param->allParams