Изменил для настроек экспорта получение данных из файлов. Сделал фикс на фронте. Сделал вывод значений кастомных свойств только для каталогов, где они были заполнены
This commit is contained in:
parent
0ceee2c0d7
commit
832b8f34b7
@ -494,7 +494,7 @@ if ($STEP === 1) {
|
|||||||
<select name="iblockPropertyProduct_" id="iblockPropertyProduct_" class="property-export" onchange="propertyChange(this)" style="width: 200px"></select>
|
<select name="iblockPropertyProduct_" id="iblockPropertyProduct_" class="property-export" onchange="propertyChange(this)" style="width: 200px"></select>
|
||||||
</td>
|
</td>
|
||||||
<td class="adm-list-table-cell">
|
<td class="adm-list-table-cell">
|
||||||
<select name="iblockPropertyProduct_" id="iblockPropertyProduct_" class="property-export" onchange="propertyChange(this)" style="width: 200px"></select>
|
<select name="iblockPropertySku_" id="iiblockPropertySku_" class="property-export" onchange="propertyChange(this)" style="width: 200px"></select>
|
||||||
<button id="delete-custom-row" class="adm-btn-save" type="button">Удалить</button>
|
<button id="delete-custom-row" class="adm-btn-save" type="button">Удалить</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -816,7 +816,7 @@ if ($STEP === 1) {
|
|||||||
let profileId = $($('input[name="PROFILE_ID"]')).val();
|
let profileId = $($('input[name="PROFILE_ID"]')).val();
|
||||||
setCustomProperties();
|
setCustomProperties();
|
||||||
|
|
||||||
if (customProperties.length > 0) {
|
if (Object.keys(customProperties).length > 0) {
|
||||||
addParamsToSetupFieldsList();
|
addParamsToSetupFieldsList();
|
||||||
BX.ajax.runAction('intaro:retailcrm.api.customexportprops.save', {
|
BX.ajax.runAction('intaro:retailcrm.api.customexportprops.save', {
|
||||||
json: {
|
json: {
|
||||||
|
@ -34,7 +34,7 @@ class CustomExportProps extends Controller
|
|||||||
$newPropertiesString .= PHP_EOL . $property['code'] . ' = ' . $property['title'];
|
$newPropertiesString .= PHP_EOL . $property['code'] . ' = ' . $property['title'];
|
||||||
}
|
}
|
||||||
$filePath = sprintf(
|
$filePath = sprintf(
|
||||||
'%s/%s_%s_%s.txt',
|
'%s/%s_profileId_%s_catalogId_%s.txt',
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/local',
|
$_SERVER['DOCUMENT_ROOT'] . '/local',
|
||||||
'icml_property_retailcrm',
|
'icml_property_retailcrm',
|
||||||
$profileId,
|
$profileId,
|
||||||
|
@ -13,9 +13,10 @@ use RetailcrmConfigProvider;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Отвечает за управление настройками выгрузки icml каталога
|
* Отвечает за управление настройками выгрузки icml каталога
|
||||||
*
|
* @var $PROFILE_ID
|
||||||
* Class SettingsService
|
* Class SettingsService
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @package Intaro\RetailCrm\Icml
|
* @package Intaro\RetailCrm\Icml
|
||||||
*/
|
*/
|
||||||
class SettingsService
|
class SettingsService
|
||||||
@ -100,6 +101,12 @@ class SettingsService
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
public $actrualPropList = [];
|
public $actrualPropList = [];
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
public $customPropList = [];
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
public $defaultPropList = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Intaro\RetailCrm\Icml\SettingsService|null
|
* @var \Intaro\RetailCrm\Icml\SettingsService|null
|
||||||
*/
|
*/
|
||||||
@ -128,7 +135,9 @@ class SettingsService
|
|||||||
$this->getPriceTypes();
|
$this->getPriceTypes();
|
||||||
$this->getVatRates();
|
$this->getVatRates();
|
||||||
|
|
||||||
$this->actrualPropList = array_merge($this->getIblockPropsPreset(), $this->parseNewProps());
|
$this->customPropList = $this->parseNewProps();
|
||||||
|
$this->defaultPropList = $this->getIblockPropsPreset();
|
||||||
|
$this->actrualPropList = $this->getActualPropList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,6 +155,21 @@ class SettingsService
|
|||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getActualPropList(): array
|
||||||
|
{
|
||||||
|
$customProps = [];
|
||||||
|
|
||||||
|
foreach ($this->customPropList as $propsByCatalog) {
|
||||||
|
$customProps = array_merge($customProps, $propsByCatalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
...$this->defaultPropList,
|
||||||
|
...$customProps
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function getPriceTypes()
|
public function getPriceTypes()
|
||||||
{
|
{
|
||||||
$dbPriceType = CCatalogGroup::GetList(['SORT' => 'ASC'], [], [], [], ['ID', 'NAME', 'BASE']);
|
$dbPriceType = CCatalogGroup::GetList(['SORT' => 'ASC'], [], [], [], ['ID', 'NAME', 'BASE']);
|
||||||
@ -230,7 +254,9 @@ class SettingsService
|
|||||||
private function setProperties(array &$properties, string $propName): void
|
private function setProperties(array &$properties, string $propName): void
|
||||||
{
|
{
|
||||||
foreach ($this->arOldSetupVars[$propName] as $iblock => $val) {
|
foreach ($this->arOldSetupVars[$propName] as $iblock => $val) {
|
||||||
$properties[$iblock][$propName] = $val;
|
if (!empty($val)) {
|
||||||
|
$properties[$iblock][$propName] = $val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,24 +289,50 @@ class SettingsService
|
|||||||
private function parseNewProps(): array
|
private function parseNewProps(): array
|
||||||
{
|
{
|
||||||
global $APPLICATION;
|
global $APPLICATION;
|
||||||
|
global $PROFILE_ID;
|
||||||
|
$currentProfile = $PROFILE_ID;
|
||||||
|
$currentProfileCatalogIds = $this->getProfileCatalogIds();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$text = $APPLICATION->GetFileContent($_SERVER["DOCUMENT_ROOT"] . "/local/icml_property_retailcrm.txt");
|
foreach ($currentProfileCatalogIds as $catalogId) {
|
||||||
|
$customPropsFilePath = sprintf(
|
||||||
|
'%s/%s_profileId_%s_catalogId_%s.txt',
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] . '/local',
|
||||||
|
'icml_property_retailcrm',
|
||||||
|
$currentProfile,
|
||||||
|
$catalogId,
|
||||||
|
);
|
||||||
|
$text = $APPLICATION->GetFileContent($customPropsFilePath);
|
||||||
|
|
||||||
if ($text === false) {
|
if ($text === false) {
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match_all('/\w+\s*=\s*\w+[ *\w+]*/mu', $text, $matches);
|
|
||||||
|
|
||||||
foreach ($matches[0] as $newProp) {
|
|
||||||
$elements = explode("=", $newProp);
|
|
||||||
|
|
||||||
if (empty($elements[0]) || empty($elements[1])) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[trim($elements[0])] = trim($elements[1]);
|
preg_match_all('/\w+\s*=\s*\w+[ *\w+]*/mu', $text, $matches);
|
||||||
|
|
||||||
|
foreach ($matches[0] as $newProp) {
|
||||||
|
$elements = explode("=", $newProp);
|
||||||
|
|
||||||
|
if (empty($elements[0]) || empty($elements[1])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result[$catalogId][trim($elements[0])] = trim($elements[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getProfileCatalogIds(): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach ($this->arOldSetupVars as $varName => $oldSetupVar) {
|
||||||
|
if (is_array($oldSetupVar) && strpos($varName, 'iblockPropertySku_') !== false) {
|
||||||
|
$result = array_keys($oldSetupVar);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
Reference in New Issue
Block a user