public function executeComponent() { if (!CModule::IncludeModule('sale')) { ShowError("Module sale not installed!"); return; } if (!CModule::IncludeModule('catalog')) { ShowError("Module catalog not installed!"); return; } $this->arResult["BITRIX_CATEGORY_ID"] = isset($this->arParams["BITRIX_CATEGORY_ID"]) ? $this->arParams["BITRIX_CATEGORY_ID"] : 0; $this->arResult["IBLOCK_ID"] = isset($this->arParams["IBLOCK_ID"]) ? $this->arParams["IBLOCK_ID"] : 0; if (isset($this->arParams["EBAY_CATEGORY_ID"])) { $this->arResult["EBAY_CATEGORY_ID"] = $this->arParams["EBAY_CATEGORY_ID"]; } else { $this->arResult["EBAY_CATEGORY_ID"] = $this->getMappedEbayCategoryId($this->arResult["BITRIX_CATEGORY_ID"]); } $this->arResult["TOP_CATEGORIES_LIST"] = $this->getTopCategories(); $this->arResult["VARIATIONS_BLOCK_ID"] = 'SALE_EBAY_CAT_' . $this->arResult["EBAY_CATEGORY_ID"] . '_VARIATIONS'; $siteRes = CIBlock::GetSite($this->arResult["IBLOCK_ID"]); //todo: It can be many sites for one iblock. if ($site = $siteRes->Fetch()) { $this->arResult["SITE_ID"] = $site["LID"]; } else { $this->arResult["SITE_ID"] = ""; } if (strlen($this->arResult["EBAY_CATEGORY_ID"]) > 0) { $this->arResult["CATEGORY_AND_PARENTS_INFO"] = $this->getCategoryAndParentsInfo($this->arResult["EBAY_CATEGORY_ID"]); if (isset($this->arResult["CATEGORY_AND_PARENTS_INFO"][1]["CATEGORY_ID"])) { $this->arResult["TOP_CATEGORY_ID"] = $this->arResult["CATEGORY_AND_PARENTS_INFO"][1]["CATEGORY_ID"]; } $this->arResult["EBAY_CATEGORY_VARIATIONS"] = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getEbayCategoryVariations($this->arResult["EBAY_CATEGORY_ID"], $this->arResult["SITE_ID"]); if (isset($this->arParams["VARIATIONS_VALUES"])) { $this->arResult["VARIATIONS_VALUES"] = $this->arParams["VARIATIONS_VALUES"]; } else { $this->arResult["VARIATIONS_VALUES"] = $this->getVariationsValues($this->arResult["IBLOCK_ID"], $this->arResult["EBAY_CATEGORY_ID"], $this->arResult["EBAY_CATEGORY_VARIATIONS"]); } } else { $this->arResult["VARIATIONS_VALUES"] = array('' => ''); $this->arResult["EBAY_CATEGORY_VARIATIONS"] = array(); } $this->arResult["CATEGORY_PROPS"] = \CIBlockSectionPropertyLink::GetArray($this->arParams["IBLOCK_ID"], $this->arParams["BITRIX_CATEGORY_ID"]); $rsProps = \CIBlockProperty::GetList(array("SORT" => "ASC", 'ID' => 'ASC'), array("IBLOCK_ID" => $this->arParams["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "ACTIVE" => "Y")); while ($arProp = $rsProps->Fetch()) { if (isset($this->arResult["CATEGORY_PROPS"][$arProp["ID"]])) { $this->arResult["CATEGORY_PROPS"][$arProp["ID"]]["NAME"] = $arProp["NAME"]; } } $this->arResult["IBLOCK_IDS"] = array($this->arParams["IBLOCK_ID"] => Loc::getMessage("SALE_EBAY_SEC_CATEGORY_PROP")); $arOffers = \CCatalogSKU::GetInfoByProductIBlock($this->arParams["IBLOCK_ID"]); if (is_array($arOffers) && !empty($arOffers)) { $this->arResult["OFFERS_IBLOCK_ID"] = $arOffers["IBLOCK_ID"]; $this->arResult["CATEGORY_OFFERS_PROPS"] = \CIBlockSectionPropertyLink::GetArray($arOffers["IBLOCK_ID"], $this->arParams["BITRIX_CATEGORY_ID"]); $rsProps = \CIBlockProperty::GetList(array("SORT" => "ASC", 'ID' => 'ASC'), array("IBLOCK_ID" => $arOffers["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "ACTIVE" => "Y")); while ($arProp = $rsProps->Fetch()) { if (isset($this->arResult["CATEGORY_OFFERS_PROPS"][$arProp["ID"]])) { $this->arResult["CATEGORY_OFFERS_PROPS"][$arProp["ID"]]["NAME"] = $arProp["NAME"]; } } $this->arResult["IBLOCK_IDS"][$arOffers["IBLOCK_ID"]] = Loc::getMessage("SALE_EBAY_SEC_OFFERS_PROP"); } $this->IncludeComponentTemplate(); }
if (isset($arResult["ERROR"]) <= 0 && $USER->IsAdmin() && check_bitrix_sessid()) { $action = isset($_REQUEST['action']) ? trim($_REQUEST['action']) : ''; switch ($action) { case "get_categories_list": $topCategory = isset($_REQUEST['topCategory']) ? intval($_REQUEST['topCategory']) : ''; $categoriesList = array(); $categoriesRes = \Bitrix\Sale\TradingPlatform\Ebay\CategoryTable::getList(array('select' => array('CATEGORY_ID', 'NAME', 'LEVEL'), 'order' => array('NAME' => 'ASC'), 'filter' => array('PARENT_ID' => $topCategory))); while ($category = $categoriesRes->fetch()) { $categoriesList[] = array($category["CATEGORY_ID"], $category["NAME"]); } $arResult["CATEGORIES_LIST"] = $categoriesList; break; case "get_variations_list": $siteId = isset($_REQUEST['siteId']) ? trim($_REQUEST['siteId']) : ''; $category = isset($_REQUEST['category']) ? trim($_REQUEST['category']) : ''; $arResult["VARIATIONS_LIST"] = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getEbayCategoryVariations($category, $siteId); break; case "get_variation_values": $variationId = isset($_REQUEST['variationId']) ? trim($_REQUEST['variationId']) : ''; $variationRes = Bitrix\Sale\TradingPlatform\Ebay\CategoryVariationTable::getById($variationId); if ($variation = $variationRes->fetch()) { $arResult["VARIATION_VALUES"] = $variation["VALUE"]; } break; case "set_category_property_link": if (!\Bitrix\Main\Loader::includeModule('iblock')) { $arResult["ERROR"] = "Can't include module Iblock!"; } $bitrixCategoryId = isset($_REQUEST['bitrixCategoryId']) ? trim($_REQUEST['bitrixCategoryId']) : ''; $properyId = isset($_REQUEST['properyId']) ? trim($_REQUEST['properyId']) : ''; CIBlockSectionPropertyLink::Add($bitrixCategoryId, $properyId);