- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/lib/component/elementlist.php
- Класс: BitrixIblockComponentElementList
- Вызов: ElementList::editTemplateOfferProps
protected function editTemplateOfferProps(&$item)
{
$matrix = array();
$newOffers = array();
$double = array();
$item['OFFERS_PROP'] = false;
$item['SKU_TREE_VALUES'] = array();
$iblockParams = $this->storage['IBLOCK_PARAMS'][$item['IBLOCK_ID']];
$skuPropList = [];
if (isset($this->arResult['SKU_PROPS'][$item['IBLOCK_ID']]))
{
$skuPropList = $this->arResult['SKU_PROPS'][$item['IBLOCK_ID']];
}
$skuPropIds = array_keys($skuPropList);
$matrixFields = array_fill_keys($skuPropIds, false);
foreach ($item['OFFERS'] as $offerKey => $offer)
{
$offer['ID'] = (int)$offer['ID'];
if (isset($double[$offer['ID']]))
continue;
$row = array();
foreach ($skuPropIds as $code)
{
$row[$code] = $this->getTemplatePropCell($code, $offer, $matrixFields, $skuPropList);
}
$matrix[$offerKey] = $row;
CIBlockPriceTools::clearProperties($offer['DISPLAY_PROPERTIES'], $iblockParams['OFFERS_TREE_PROPS']);
CIBlockPriceTools::setRatioMinPrice($offer, false);
if ($this->arParams['SHOW_SLIDER'] === 'Y')
{
$this->editTemplateOfferSlider($offer, $item['IBLOCK_ID'], 5, true, $item['MORE_PHOTO']);
}
$offerPictures = CIBlockPriceTools::getDoublePicturesForItem($offer, $iblockParams['OFFERS_ADD_PICT_PROP']);
$offer['OWNER_PICT'] = empty($offerPictures['PICT']);
$offer['PREVIEW_PICTURE'] = false;
$offer['PREVIEW_PICTURE_SECOND'] = false;
$offer['SECOND_PICT'] = true;
if (!$offer['OWNER_PICT'])
{
if (empty($offerPictures['SECOND_PICT']))
{
$offerPictures['SECOND_PICT'] = $offerPictures['PICT'];
}
$offer['PREVIEW_PICTURE'] = $offerPictures['PICT'];
$offer['PREVIEW_PICTURE_SECOND'] = $offerPictures['SECOND_PICT'];
}
if ($iblockParams['OFFERS_ADD_PICT_PROP'] != '' && isset($offer['DISPLAY_PROPERTIES'][$iblockParams['OFFERS_ADD_PICT_PROP']]))
{
unset($offer['DISPLAY_PROPERTIES'][$iblockParams['OFFERS_ADD_PICT_PROP']]);
}
$offer['TREE'] = [];
$double[$offer['ID']] = true;
$newOffers[$offerKey] = $offer;
}
$item['OFFERS'] = $newOffers;
$usedFields = array();
$sortFields = array();
$matrixKeys = array_keys($matrix);
foreach ($skuPropIds as $propCode)
{
$boolExist = $matrixFields[$propCode];
foreach ($matrixKeys as $offerKey)
{
if ($boolExist)
{
$propId = $this->arResult['SKU_PROPS'][$item['IBLOCK_ID']][$propCode]['ID'];
$value = $matrix[$offerKey][$propCode]['VALUE'];
if (!isset($item['SKU_TREE_VALUES'][$propId]))
{
$item['SKU_TREE_VALUES'][$propId] = array();
}
$item['SKU_TREE_VALUES'][$propId][$value] = true;
$item['OFFERS'][$offerKey]['TREE']['PROP_'.$propId] = $value;
$item['OFFERS'][$offerKey]['SKU_SORT_'.$propCode] = $matrix[$offerKey][$propCode]['SORT'];
$usedFields[$propCode] = true;
$sortFields['SKU_SORT_'.$propCode] = SORT_NUMERIC;
unset($value, $propId);
}
else
{
unset($matrix[$offerKey][$propCode]);
}
}
unset($offerKey);
}
unset($propCode, $matrixKeys);
$item['OFFERS_PROP'] = $usedFields;
$item['OFFERS_PROP_CODES'] = !empty($usedFields) ? base64_encode(serialize(array_keys($usedFields))) : '';
Collection::sortByColumn($item['OFFERS'], $sortFields);
}