- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/sectionslist.php
- Класс: BitrixSaleTradingPlatformVkSectionsList
- Вызов: SectionsList::prepareSectionToSave
public function prepareSectionToSave($sectionId)
{
$settings = $this->currSectionSettings;
if (empty($settings))
{
return false;
}
$sections = $this->getSections(false, false);
$iblockId = $sections[$sectionId]["IBLOCK_ID"];
$currParentSettings = $this->mappedSections[$sectionId]['PARAMS']['PARENT_SETTINGS'];
$dataToDelete = array();
$settingsToSave = array();
// common params to save
$settingsToSave["IBLOCK"] = $iblockId;
$settingsToSave["PARENT_SETTINGS"] = $currParentSettings;
// if INHERIT - only one flag, no need settings
// or if ROOT sections (newer have parent) and not enable - delete them from mapping
if (
(isset($settings["INHERIT"]) && $settings["INHERIT"]) ||
(!$sections[$sectionId]["IBLOCK_SECTION_ID"] && !$settings["ENABLE"])
)
{
// if INHERIT and have not parent settings - delete this item
if (!$currParentSettings)
{
$dataToDelete = array(
"VALUE_EXTERNAL" => $settings["VK_CATEGORY"] ? $settings["VK_CATEGORY"] : Vk::VERY_DEFAULT_VK_CATEGORY,
"VALUE_INTERNAL" => $sectionId,
);
}
else
{
$settingsToSave["INHERIT"] = true;
}
}
else
{
$settingsToSave["INHERIT"] = false;
// if disable - only flag
if (!$settings["ENABLE"])
{
$settingsToSave["ENABLE"] = false;
}
// ENABLE and not INHERIT
else
{
$settingsToSave["ENABLE"] = true;
$settingsToSave["INCLUDE_CHILDS"] = $settings["INCLUDE_CHILDS"] ? true : false;
$settingsToSave["VK_CATEGORY"] = $settings["VK_CATEGORY"] != 0 ? $settings["VK_CATEGORY"] : Vk::VK_CATEGORY_TO_CHANGE;
if (isset($settings["TO_ALBUM"]) && $settings["TO_ALBUM"] > 0)
{
$settingsToSave["TO_ALBUM"] = $settings["TO_ALBUM"];
if (
isset($settings["TO_ALBUM_ALIAS"]) && $settings["TO_ALBUM_ALIAS"] &&
$settings["TO_ALBUM"] == $sectionId
)
{
$settingsToSave["TO_ALBUM_ALIAS"] = $settings["TO_ALBUM_ALIAS"];
}
else
{
$settingsToSave["TO_ALBUM_ALIAS"] = null;
}
}
else
{
$settingsToSave["TO_ALBUM"] = 0;
$settingsToSave["TO_ALBUM_ALIAS"] = null;
}
}
}
// VALUE_EXTERNAL is required, but we might be have not this value. Get some default
if (!empty($dataToDelete))
{
return array(
"TO_DELETE" => array(
$sectionId => $dataToDelete,
),
);
}
else
{
return array(
"TO_SAVE" => array(
$sectionId => array(
"VALUE_EXTERNAL" => $settings["VK_CATEGORY"] ? $settings["VK_CATEGORY"] : Vk::VERY_DEFAULT_VK_CATEGORY,
"VALUE_INTERNAL" => $sectionId,
"PARAMS" => $settingsToSave,
),
),
);
}
}