1
0
mirror of synced 2024-11-23 05:46:09 +03:00

Сделал сохранение свойств для всех каталогов. Убрал вывод свойств, для которых не заданы коды

This commit is contained in:
a.belikin 2024-11-12 19:27:48 +03:00
parent 7c762dff2f
commit 7b9c2e4f96
2 changed files with 33 additions and 31 deletions

View File

@ -190,8 +190,7 @@ if ($STEP === 1) {
<tbody> <tbody>
<?php <?php
foreach ($settingsService->defaultPropList as $propertyKey => $property) { foreach ($settingsService->defaultPropList as $propertyKey => $property) { ?>
$productSelected = false; ?>
<tr class="adm-list-table-row"> <tr class="adm-list-table-row">
<td class="adm-list-table-cell"> <td class="adm-list-table-cell">
@ -215,14 +214,14 @@ if ($STEP === 1) {
if ($keyField === $propertyKey) { ?> if ($keyField === $propertyKey) { ?>
<option value="<?=$field['CODE']?>" <option value="<?=$field['CODE']?>"
<?php <?php
$productSelected = $settingsService->isOptionSelected( $isSelected = $settingsService->isOptionSelected(
$field, $field,
$arIBlock['OLD_PROPERTY_PRODUCT_SELECT'], $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'],
$propertyKey $propertyKey
); );
?> ?>
<?= $productSelected ? ' selected' : ''?> <?= $isSelected ? ' selected' : ''?>
> >
<?=$field['name']?> <?=$field['name']?>
</option> </option>
@ -241,7 +240,7 @@ if ($STEP === 1) {
<?php <?php
echo $settingsService->getOptionClass($prop, true); echo $settingsService->getOptionClass($prop, true);
$productSelected = $settingsService->isOptionSelected( $isSelected = $settingsService->isOptionSelected(
$prop, $prop,
$arIBlock['OLD_PROPERTY_PRODUCT_SELECT'], $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'],
$propertyKey $propertyKey
@ -251,7 +250,7 @@ if ($STEP === 1) {
= $settingsService->getHlTableName($prop) = $settingsService->getHlTableName($prop)
?? $productHlTableName; ?? $productHlTableName;
echo $productSelected ? ' selected' : ''; echo $isSelected ? ' selected' : '';
?> ?>
> >
<?=$prop['NAME']?> <?=$prop['NAME']?>
@ -376,7 +375,7 @@ if ($STEP === 1) {
<option value="<?=$prop['CODE']?>" <option value="<?=$prop['CODE']?>"
<?php <?php
echo $settingsService->getOptionClass($prop, false); echo $settingsService->getOptionClass($prop, false);
if (!$productSelected) {
$isSelected = $settingsService->isOptionSelected( $isSelected = $settingsService->isOptionSelected(
$prop, $prop,
$arIBlock['OLD_PROPERTY_SKU_SELECT'], $arIBlock['OLD_PROPERTY_SKU_SELECT'],
@ -388,7 +387,6 @@ if ($STEP === 1) {
?? $skuHlTableName; ?? $skuHlTableName;
echo $isSelected ? ' selected' : ''; echo $isSelected ? ' selected' : '';
}
?> ?>
> >
<?=$prop['NAME']?> <?=$prop['NAME']?>
@ -475,7 +473,6 @@ if ($STEP === 1) {
} ?> } ?>
<?php <?php
$productSelected = false;
$catalogId = $arIBlock['ID']; $catalogId = $arIBlock['ID'];
$catalogCustomProps = $settingsService->customPropList[$catalogId]; $catalogCustomProps = $settingsService->customPropList[$catalogId];
@ -500,7 +497,7 @@ if ($STEP === 1) {
<?php <?php
echo $settingsService->getOptionClass($prop, true); echo $settingsService->getOptionClass($prop, true);
$productSelected = $settingsService->isOptionSelected( $isSelected = $settingsService->isOptionSelected(
$prop, $prop,
$arIBlock['OLD_PROPERTY_PRODUCT_SELECT'], $arIBlock['OLD_PROPERTY_PRODUCT_SELECT'],
$catalogCustomPropCode $catalogCustomPropCode
@ -510,7 +507,7 @@ if ($STEP === 1) {
= $settingsService->getHlTableName($prop) = $settingsService->getHlTableName($prop)
?? $productHlTableName; ?? $productHlTableName;
echo $productSelected ? ' selected' : ''; echo $isSelected ? ' selected' : '';
?> ?>
> >
<?=$prop['NAME']?> <?=$prop['NAME']?>
@ -519,12 +516,11 @@ if ($STEP === 1) {
</select> </select>
</td> </td>
<?php if ($arIBlock['PROPERTIES_SKU'] !== null) { <?php if ($arIBlock['PROPERTIES_SKU'] !== null) { ?>
$productSelected = false; ?>
<td class="adm-list-table-cell"> <td class="adm-list-table-cell">
<select <select
name="iblockPropertyProduct_<?=$catalogCustomPropCode?>[<?= $catalogId ?>]" name="iblockPropertySku_<?=$catalogCustomPropCode?>[<?= $catalogId ?>]"
id="iblockPropertyProduct_<?=$catalogCustomPropCode . $catalogId ?>" id="iblockPropertySku_<?=$catalogCustomPropCode . $catalogId ?>"
class="property-export" class="property-export"
data-type="<?= $catalogCustomPropCode ?>" data-type="<?= $catalogCustomPropCode ?>"
onchange="propertyChange(this)" onchange="propertyChange(this)"
@ -537,7 +533,6 @@ if ($STEP === 1) {
<?php <?php
echo $settingsService->getOptionClass($prop, false); echo $settingsService->getOptionClass($prop, false);
if (!$productSelected) {
$isSelected = $settingsService->isOptionSelected( $isSelected = $settingsService->isOptionSelected(
$prop, $prop,
$arIBlock['OLD_PROPERTY_SKU_SELECT'], $arIBlock['OLD_PROPERTY_SKU_SELECT'],
@ -549,7 +544,6 @@ if ($STEP === 1) {
?? $skuHlTableName; ?? $skuHlTableName;
echo $isSelected ? ' selected' : ''; echo $isSelected ? ' selected' : '';
}
?> ?>
> >
<?=$prop['NAME']?> <?=$prop['NAME']?>
@ -766,6 +760,7 @@ if ($STEP === 1) {
function propertyChange(obj) { function propertyChange(obj) {
let selectedOption = $(obj).find('option')[obj.selectedIndex]; let selectedOption = $(obj).find('option')[obj.selectedIndex];
console.log(selectedOption);
if (selectedOption.className === 'not-highloadblock') { if (selectedOption.className === 'not-highloadblock') {
let objId = '#' + obj.id; let objId = '#' + obj.id;
@ -932,7 +927,7 @@ if ($STEP === 1) {
properties: customProps, properties: customProps,
profileId: profileId profileId: profileId
}, },
}).then(addParamsToSetupFieldsList); }).then(addParamsToSetupFieldsList());
} }
if (Object.keys(customPropsToDelete).length > 0) { if (Object.keys(customPropsToDelete).length > 0) {
@ -941,7 +936,7 @@ if ($STEP === 1) {
properties: customPropsToDelete, properties: customPropsToDelete,
profileId: profileId profileId: profileId
}, },
}).then(deleteParamsFromSetupFieldsList); }).then(deleteParamsFromSetupFieldsList());
} }
const promises = [savePromise, deletePromise].filter(Boolean); const promises = [savePromise, deletePromise].filter(Boolean);

View File

@ -541,6 +541,9 @@ class SettingsService
*/ */
public function isOptionSelected(array $prop, array $oldSelect, string $key): bool public function isOptionSelected(array $prop, array $oldSelect, string $key): bool
{ {
if ($key === 'manufacturer') {
$a = 'yes';
}
if (count($oldSelect) > 0) { if (count($oldSelect) > 0) {
if ($prop['CODE'] === $oldSelect[$key]) { if ($prop['CODE'] === $oldSelect[$key]) {
return true; return true;
@ -635,9 +638,11 @@ class SettingsService
$dbSkuProperties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], [], ['MULTIPLE' => 'N']); $dbSkuProperties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], [], ['MULTIPLE' => 'N']);
while ($prop = $dbSkuProperties->Fetch()) { while ($prop = $dbSkuProperties->Fetch()) {
if ($prop['CODE'] !== '') {
$propertiesSKU[] = $prop; $propertiesSKU[] = $prop;
} }
} }
}
return $propertiesSKU; return $propertiesSKU;
} }
@ -689,8 +694,10 @@ class SettingsService
$iblockResult = CIBlock::GetProperties($iblockId, [], ['MULTIPLE' => 'N']); $iblockResult = CIBlock::GetProperties($iblockId, [], ['MULTIPLE' => 'N']);
while ($prop = $iblockResult->Fetch()) { while ($prop = $iblockResult->Fetch()) {
if ($prop['CODE'] !== '') {
$propertiesProduct[] = $prop; $propertiesProduct[] = $prop;
} }
}
return $propertiesProduct; return $propertiesProduct;
} }