This commit is contained in:
parent
830fe34e3e
commit
7f69ebfa1f
@ -1,3 +1,6 @@
|
||||
## 2024-03-28 v.6.5.12
|
||||
- Исправлена подстановка домена при генерации каталога
|
||||
|
||||
## 2024-03-28 v.6.5.11
|
||||
- Исправлена ошибка дублирования скидок
|
||||
|
||||
|
@ -1 +1 @@
|
||||
- Исправлена ошибка дублирования скидок
|
||||
- Исправлена подстановка домена при генерации каталога
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.5.11',
|
||||
'VERSION_DATE' => '2024-03-28 12:00:00'
|
||||
'VERSION' => '6.5.12',
|
||||
'VERSION_DATE' => '2024-03-28 17:00:00'
|
||||
];
|
||||
|
@ -91,9 +91,10 @@ class XmlCategoryDirector
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$xmlCategory = $this->xmlCategoryFactory->create(
|
||||
$category,
|
||||
$this->fileRepository->getImageUrl($category->get('PICTURE'))
|
||||
$this->fileRepository->getImageUrl($category->get('PICTURE'), $category->get('IBLOCK_ID'))
|
||||
);
|
||||
|
||||
if (!$xmlCategory) {
|
||||
@ -102,7 +103,7 @@ class XmlCategoryDirector
|
||||
|
||||
$xmlCategories[$categoryKey] = $this->xmlCategoryFactory->create(
|
||||
$category,
|
||||
$this->fileRepository->getImageUrl($category->get('PICTURE'))
|
||||
$this->fileRepository->getImageUrl($category->get('PICTURE'), $category->get('IBLOCK_ID'))
|
||||
);
|
||||
} catch (ArgumentException | SystemException $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
@ -130,7 +131,7 @@ class XmlCategoryDirector
|
||||
try {
|
||||
return $this->xmlCategoryFactory->create(
|
||||
$iblock,
|
||||
$this->fileRepository->getImageUrl($iblock->get('PICTURE')),
|
||||
$this->fileRepository->getImageUrl($iblock->get('PICTURE'), $iblockId),
|
||||
$categoryId
|
||||
);
|
||||
} catch (ArgumentException | SystemException $exception) {
|
||||
|
@ -42,7 +42,7 @@ class XmlOfferBuilder
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $defaultServerName;
|
||||
private $serverName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@ -106,16 +106,16 @@ class XmlOfferBuilder
|
||||
*
|
||||
* @param \Intaro\RetailCrm\Model\Bitrix\Xml\XmlSetup $setup
|
||||
* @param array $measure
|
||||
* @param string|null $defaultServerName
|
||||
* @param string|null $serverName
|
||||
*/
|
||||
public function __construct(XmlSetup $setup, array $measure, ?string $defaultServerName)
|
||||
public function __construct(XmlSetup $setup, array $measure, ?string $serverName)
|
||||
{
|
||||
$this->setup = $setup;
|
||||
$this->purchasePriceNull = RetailcrmConfigProvider::getCrmPurchasePrice();
|
||||
$this->settingsService = SettingsService::getInstance([], '');
|
||||
$this->vatRates = $this->settingsService->vatRates;
|
||||
$this->measures = $this->prepareMeasures($measure);
|
||||
$this->defaultServerName = $defaultServerName;
|
||||
$this->serverName = $serverName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,6 +198,11 @@ class XmlOfferBuilder
|
||||
$this->productPicture = $getProductPicture;
|
||||
}
|
||||
|
||||
public function setServerName(string $serverName): void
|
||||
{
|
||||
$this->serverName = $serverName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляет в XmlOffer значения настраиваемых параметров, производителя, вес и габариты
|
||||
*/
|
||||
@ -242,7 +247,7 @@ class XmlOfferBuilder
|
||||
$this->xmlOffer->productType = (int) $item['CATALOG_TYPE'];
|
||||
$this->xmlOffer->quantity = $item['CATALOG_QUANTITY'] ?? '';
|
||||
$this->xmlOffer->url = $item['DETAIL_PAGE_URL']
|
||||
? $this->defaultServerName . $item['DETAIL_PAGE_URL']
|
||||
? $this->serverName . $item['DETAIL_PAGE_URL']
|
||||
: '';
|
||||
$this->xmlOffer->price = $item['CATALOG_PRICE_' . $this->setup->basePriceId];
|
||||
$this->xmlOffer->purchasePrice = $this->getPurchasePrice(
|
||||
|
@ -74,6 +74,8 @@ class XmlOfferDirector
|
||||
$ciBlockResult = $this->catalogRepository->getProductPage($param, $catalogIblockInfo, $this->setup->loadNonActivity);
|
||||
$offers = [];
|
||||
|
||||
$this->xmlOfferBuilder->setServerName($this->fileRepository->getServerName($catalogIblockInfo->productIblockId));
|
||||
|
||||
while ($offer = $ciBlockResult->Fetch()) {
|
||||
$categories = $this->catalogRepository->getProductCategories($offer['ID']);
|
||||
$offer['DETAIL_PAGE_URL'] = $this->replaceUrlTemplate($offer, $categories);
|
||||
@ -211,7 +213,7 @@ class XmlOfferDirector
|
||||
$this->xmlOfferBuilder->setPicturesPath(
|
||||
$this
|
||||
->fileRepository
|
||||
->getProductPicture($product, $pictureProperty ?? '')
|
||||
->getProductPicture($product, $pictureProperty ?? '', $catalogIblockInfo->productIblockId)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,9 @@ class FileRepository
|
||||
*/
|
||||
private $defaultServerName;
|
||||
|
||||
/** @var array */
|
||||
private $domainCatalogList = [];
|
||||
|
||||
/**
|
||||
* FileRepository constructor.
|
||||
* @param string $defaultServerName
|
||||
@ -22,13 +25,14 @@ class FileRepository
|
||||
public function __construct(string $defaultServerName)
|
||||
{
|
||||
$this->defaultServerName = $defaultServerName;
|
||||
$this->domainCatalogList = SiteRepository::getDomainList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $fileId
|
||||
* @return string
|
||||
*/
|
||||
public function getImageUrl(?int $fileId): string
|
||||
public function getImageUrl(?int $fileId, ?int $iBlockId = null): string
|
||||
{
|
||||
if (!$fileId) {
|
||||
return '';
|
||||
@ -38,7 +42,7 @@ class FileRepository
|
||||
$validation = '/^(http|https):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i';
|
||||
|
||||
if ((bool) preg_match($validation, $pathImage) === false) {
|
||||
return $this->defaultServerName . $pathImage;
|
||||
return $this->getServerName($iBlockId) . $pathImage;
|
||||
}
|
||||
|
||||
return $pathImage;
|
||||
@ -49,19 +53,24 @@ class FileRepository
|
||||
* @param string $pictureProp
|
||||
* @return string
|
||||
*/
|
||||
public function getProductPicture(array $product, string $pictureProp = ''): string
|
||||
public function getProductPicture(array $product, string $pictureProp = '', ?int $iBlockId = null): string
|
||||
{
|
||||
$picture = '';
|
||||
$pictureId = $product['PROPERTY_' . $pictureProp . '_VALUE'] ?? null;
|
||||
|
||||
if (isset($product['DETAIL_PICTURE'])) {
|
||||
$picture = $this->getImageUrl($product['DETAIL_PICTURE']);
|
||||
$picture = $this->getImageUrl($product['DETAIL_PICTURE'], $iBlockId);
|
||||
} elseif (isset($product['PREVIEW_PICTURE'])) {
|
||||
$picture = $this->getImageUrl($product['PREVIEW_PICTURE']);
|
||||
$picture = $this->getImageUrl($product['PREVIEW_PICTURE'], $iBlockId);
|
||||
} elseif ($pictureId !== null) {
|
||||
$picture = $this->getImageUrl($pictureId);
|
||||
$picture = $this->getImageUrl($pictureId, $iBlockId);
|
||||
}
|
||||
|
||||
return $picture ?? '';
|
||||
}
|
||||
|
||||
public function getServerName(?int $iBlockId): string
|
||||
{
|
||||
return $this->domainCatalogList[$iBlockId] ?? $this->defaultServerName;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace Intaro\RetailCrm\Repository;
|
||||
|
||||
use CSite;
|
||||
use RetailcrmConfigProvider;
|
||||
use Bitrix\Iblock\IblockTable;
|
||||
|
||||
/**
|
||||
* Class SiteRepository
|
||||
@ -26,4 +27,43 @@ class SiteRepository
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getDomainList(): ?array
|
||||
{
|
||||
$result = [];
|
||||
$resultBlock = [];
|
||||
$resultSites = [];
|
||||
|
||||
try {
|
||||
$iBlockResult = IblockTable::GetList(['select' => ['ID', 'LID']], $sort, ['ACTIVE' => 'Y']);
|
||||
|
||||
while ($iBlock = $iBlockResult->Fetch()) {
|
||||
$resultBlock[] = $iBlock;
|
||||
}
|
||||
|
||||
$resultBlock = array_column($resultBlock, 'LID', 'ID');
|
||||
|
||||
$rsSites = CSite::GetList($by, $sort, ['ACTIVE' => 'Y']);
|
||||
|
||||
while ($site = $rsSites->Fetch()) {
|
||||
$resultSites[] = $site;
|
||||
}
|
||||
|
||||
$resultSites = array_column($resultSites, 'SERVER_NAME', 'LID');
|
||||
|
||||
foreach ($resultBlock as $id => $lid) {
|
||||
if (isset($resultSites[$lid])) {
|
||||
$result[$id] = RetailcrmConfigProvider::getProtocol() . $resultSites[$lid];
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
RCrmActions::eventLog(
|
||||
'SiteRepository:getDomainList',
|
||||
'domain',
|
||||
'Error when obtaining domains: ' . $exception->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user