1
0
Fork 0
mirror of synced 2025-04-11 05:00:55 +00:00
Добавлена выгрузка дополнительных свойств товаров
This commit is contained in:
Ivan Chaplygin 2024-01-11 15:14:09 +03:00
parent 16e6ddaa29
commit a6233b14ea
4 changed files with 31 additions and 30 deletions

View file

@ -37,8 +37,8 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
$hlblockList[$hlblockArr["TABLE_NAME"]] = $hlblockArr;
}
}
$iblockProperties = SettingsService::getIblockPropsPreset();
$settingService = SettingsService::getInstance([], '');
$iblockProperties = $settingService->actrualPropList;
$iblockPropertySku = [];
$iblockPropertySkuHl = [];
@ -47,7 +47,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/exp
$iblockPropertyProductHl = [];
$iblockPropertyUnitProduct = [];
foreach ($iblockProperties as $prop) {
foreach ($iblockProperties as $prop => $text) {
$skuUnitProps = ('iblockPropertyUnitSku_' . $prop);
$skuUnitProps = $$skuUnitProps;

View file

@ -63,7 +63,7 @@ if (($ACTION === 'EXPORT' || $ACTION === 'EXPORT_EDIT' || $ACTION === 'EXPORT_CO
$SETUP_FILE_NAME = $settingsService->setupFileName;
$SETUP_PROFILE_NAME = $settingsService->setupProfileName;
$iblockProperties = $settingsService::getIblockPropsPreset();
$iblockProperties = $settingsService->actrualPropList;
$loadPurchasePrice = $settingsService->loadPurchasePrice;
$iblockExport = $settingsService->iblockExport;
$loadNonActivity = $settingsService->loadNonActivity;
@ -192,7 +192,7 @@ if ($STEP === 1) {
<tbody>
<?php
foreach ($settingsService->getIblockPropsNames() as $propertyKey => $property) {
foreach ($settingsService->actrualPropList as $propertyKey => $property) {
$productSelected = false; ?>
<tr class="adm-list-table-row">

View file

@ -245,7 +245,7 @@ class SettingsService
/**
* @return string[]
*/
public function getIblockPropsPreset(): array
private function getIblockPropsPreset(): array
{
return [
'article' => GetMessage('PROPERTY_ARTICLE_HEADER_NAME'),
@ -262,9 +262,28 @@ class SettingsService
private function parseNewProps(): array
{
global $APPLICATION;
$result = [];
$text = $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . "/local/addProperty.txt");
if ($text === false) {
return $result;
}
preg_match_all('/\w+\s*=\s*\w+/mu', $text, $matches);
foreach ($matches[0] as $newProp) {
$elements = explode("=", $newProp);
if (empty($elements[0]) || empty($elements[1])) {
continue;
}
$result[trim($elements[0])] = trim($elements[1]);
}
return $result;
}
/**
@ -285,24 +304,6 @@ class SettingsService
];
}
/**
* @return array
*/
public function getIblockPropsNames(): array
{
return [
'article' => GetMessage('PROPERTY_ARTICLE_HEADER_NAME'),
'manufacturer' => GetMessage('PROPERTY_MANUFACTURER_HEADER_NAME'),
'color' => GetMessage('PROPERTY_COLOR_HEADER_NAME'),
'size' => GetMessage('PROPERTY_SIZE_HEADER_NAME'),
'weight' => GetMessage('PROPERTY_WEIGHT_HEADER_NAME'),
'length' => GetMessage('PROPERTY_LENGTH_HEADER_NAME'),
'width' => GetMessage('PROPERTY_WIDTH_HEADER_NAME'),
'height' => GetMessage('PROPERTY_HEIGHT_HEADER_NAME'),
'picture' => GetMessage('PROPERTY_PICTURE_HEADER_NAME'),
];
}
/**
* @return array[]
*/
@ -364,7 +365,7 @@ class SettingsService
public function setProps(): void
{
foreach ($this->getIblockPropsPreset() as $prop) {
foreach ($this->actrualPropList as $prop => $text) {
$this->setProperties($this->iblockPropertySku, 'iblockPropertySku_' . $prop);
$this->setProperties($this->iblockPropertyUnitSku, 'iblockPropertyUnitSku_' . $prop);
$this->setProperties($this->iblockPropertyProduct, 'iblockPropertyProduct_' . $prop);
@ -440,7 +441,7 @@ class SettingsService
{
$values = 'loadPurchasePrice,SETUP_FILE_NAME,iblockExport,maxOffersValue,loadNonActivity';
foreach ($iblockProperties as $val) {
foreach ($iblockProperties as $val => $text) {
$values .= ',iblockPropertySku_' . $val
. ',iblockPropertyUnitSku_' . $val
. ',iblockPropertyProduct_' . $val
@ -600,9 +601,9 @@ class SettingsService
$props = [];
if (isset($oldValues[$iblockId])) {
foreach ($this->getIblockPropsNames() as $key => $prop) {
$fullKey = $keyGroup . '_' . $key;
$props[$key] = $oldValues[$iblockId][$fullKey];
foreach ($this->actrualPropList as $prop => $text) {
$fullKey = $keyGroup . '_' . $prop;
$props[$prop] = $oldValues[$iblockId][$fullKey];
}
}

View file

@ -465,7 +465,7 @@ class XmlOfferBuilder
private function createParamObject(array $params): array
{
$offerParams = [];
$names = $this->settingsService->getIblockPropsNames();
$names = $this->settingsService->actrualPropList;
foreach ($params as $code => $value) {