Catalog fix
* add empty array Instead of and add xml-header with charsets * fix catalog purchasePrice * use file_put_contents for flush
This commit is contained in:
parent
380e1f0081
commit
3e5a04af62
@ -25,7 +25,7 @@ CModule::IncludeModule('intaro.retailcrm');
|
||||
|
||||
//TODO заменить вызов на сервис-локатор, когда он приедет
|
||||
$settingsService = SettingsService::getInstance(
|
||||
$arOldSetupVars,
|
||||
$arOldSetupVars ?? [],
|
||||
$ACTION
|
||||
);
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace Intaro\RetailCrm\Icml;
|
||||
|
||||
use COption;
|
||||
use Intaro\RetailCrm\Icml\Utils\IcmlUtils;
|
||||
use Bitrix\Catalog\ProductTable;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Orm\CatalogIblockInfo;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\SelectParams;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\XmlData;
|
||||
@ -178,6 +177,7 @@ class IcmlDirector
|
||||
$this->setup->properties->products->names[$productIblockId],
|
||||
$this->setup->basePriceId
|
||||
);
|
||||
|
||||
$paramsForOffer
|
||||
= $this->queryBuilder->getSelectParams(
|
||||
$this->setup->properties->sku->names[$productIblockId],
|
||||
@ -249,6 +249,12 @@ class IcmlDirector
|
||||
$paramsForOffer->allParams = array_merge($paramsForOffer->configurable, $paramsForOffer->main);
|
||||
|
||||
do {
|
||||
//Если каталог проиндексирован, у товара есть Тип и это простой товар, то просто записываем его
|
||||
if ($product->productType = ProductTable::TYPE_PRODUCT) {
|
||||
$this->icmlWriter->writeOffers([$product]);
|
||||
break;
|
||||
}
|
||||
|
||||
$xmlOffersPart
|
||||
= $this->xmlOfferDirector->getXmlOffersBySingleProduct($paramsForOffer, $catalogIblockInfo, $product);
|
||||
|
||||
|
@ -23,16 +23,23 @@ class IcmlWriter
|
||||
* @var \XMLWriter
|
||||
*/
|
||||
private $writer;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $filePath;
|
||||
|
||||
/**
|
||||
* IcmlWriter constructor.
|
||||
* @param $filePath
|
||||
*
|
||||
* @param string $filePath
|
||||
*/
|
||||
public function __construct($filePath)
|
||||
public function __construct(string $filePath)
|
||||
{
|
||||
$this->filePath = $filePath;
|
||||
$this->writer = new XMLWriter();
|
||||
$this->writer->openURI($_SERVER['DOCUMENT_ROOT'] . $filePath);
|
||||
$this->writer->setIndent(true);
|
||||
$this->writer->openMemory();
|
||||
$this->writer->setIndent(false);
|
||||
$this->writer->startDocument('1.0', LANG_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +59,8 @@ class IcmlWriter
|
||||
{
|
||||
$this->writer->endElement();
|
||||
$this->writer->endElement();
|
||||
$this->writer->flush();
|
||||
file_put_contents($this->filePath, $this->writer->flush(true), FILE_APPEND);
|
||||
$this->writer->endDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,12 +77,12 @@ class IcmlWriter
|
||||
count($data->categories) === $key + 1
|
||||
|| is_int(count($data->categories) / self::CATEGORY_PART)
|
||||
) {
|
||||
$this->writer->flush();
|
||||
file_put_contents($this->filePath, $this->writer->flush(true), FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writer->endElement();
|
||||
$this->writer->flush();
|
||||
file_put_contents($this->filePath, $this->writer->flush(true), FILE_APPEND);
|
||||
}
|
||||
|
||||
public function startOffersBlock(): void
|
||||
@ -96,7 +104,7 @@ class IcmlWriter
|
||||
$this->writeOffer($offer);
|
||||
}
|
||||
|
||||
$this->writer->flush();
|
||||
file_put_contents($this->filePath, $this->writer->flush(true), FILE_APPEND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,6 +50,7 @@ class QueryParamsMolder
|
||||
'PREVIEW_PICTURE',
|
||||
'DETAIL_PAGE_URL',
|
||||
'CATALOG_QUANTITY',
|
||||
'CATALOG_TYPE',
|
||||
'CATALOG_PRICE_' . $basePriceId,
|
||||
'CATALOG_PURCHASING_PRICE',
|
||||
'EXTERNAL_ID',
|
||||
|
@ -225,6 +225,7 @@ class XmlOfferBuilder
|
||||
{
|
||||
$this->xmlOffer->id = $item['ID'];
|
||||
$this->xmlOffer->productId = $item['ID'];
|
||||
$this->xmlOffer->productType = $item['CATALOG_TYPE'];
|
||||
$this->xmlOffer->quantity = $item['CATALOG_QUANTITY'] ?? '';
|
||||
$this->xmlOffer->url = $item['DETAIL_PAGE_URL']
|
||||
? $this->defaultServerName . $item['DETAIL_PAGE_URL']
|
||||
|
@ -119,6 +119,16 @@ class XmlOffer
|
||||
*/
|
||||
public $dimensions;
|
||||
|
||||
/**
|
||||
* Тип каталога
|
||||
* \Bitrix\Catalog\ProductTable::TYPE_PRODUCT - простой товар
|
||||
* \Bitrix\Catalog\ProductTable::TYPE_SKU – товар с торговыми предложениями
|
||||
* \Bitrix\Catalog\ProductTable::TYPE_OFFER – торговое предложение
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $productType;
|
||||
|
||||
/**
|
||||
* @param $productValue
|
||||
* @param $offerValue
|
||||
|
@ -93,7 +93,7 @@ class CatalogRepository
|
||||
public function getProductPage(SelectParams $param, CatalogIblockInfo $catalogIblockInfo)
|
||||
{
|
||||
return CIBlockElement::GetList(
|
||||
[],
|
||||
['ID' => 'ASC'],
|
||||
$this->builder->getWhereForOfferPart($param->parentId, $catalogIblockInfo),
|
||||
false,
|
||||
['nPageSize' => $param->nPageSize, 'iNumPage' => $param->pageNumber, 'checkOutOfRange' => true],
|
||||
|
Loading…
Reference in New Issue
Block a user