function __construct($prof) { global $USER; if (!is_object($USER)) { $USER = new CUser(); } CModule::IncludeModule("iblock"); if (CModule::IncludeModule("catalog")) { $this->isCat = true; } else { $this->isCat = false; } $pro = new CProfileAdmin(); $cgm = new CGMExport(); $pr = $pro->GetByID($prof)->Fetch(); $this->ID = $pr["ID"]; $this->Name = $pr["NAME"]; $this->TYPE_RUN = $pr["TYPE_RUN"]; $this->FEED = $pr["FEED"]; $this->COMPANY = $pr["COMPANY"]; $this->SHOPNAME = $pr["SHOPNAME"]; $this->DOMAIN_NAME = $pr["DOMAIN_NAME"]; $this->ACTIVE = $pr["ACTIVE"] == "Y" ? true : false; $this->ENCODING = $pr["ENCODING"]; $this->IBLOCK_ID = unserialize(base64_decode($pr["IBLOCK_ID"])); $this->SECTION_ID = unserialize(base64_decode($pr["SECTION_ID"])); $this->GOOGLE_CATEGORY = unserialize(base64_decode($pr["GOOGLE_CATEGORY"])); $this->CONDITIONS = $pr["CONDITIONS"]; $this->LID = $pr["LID"]; $this->DETAIL_PAGE_URL = $pr["DETAIL_PAGE_URL"]; $this->USE_SKU = $pr["USE_SKU"] == "Y" ? true : false; $this->CHECK_INCLUDE = $pr["CHECK_INCLUDE"] == "Y" ? true : false; $this->FORORDER = $pr["FORORDER"] == "Y" ? true : false; $this->OTHER = $pr["OTHER"] == "Y" ? true : false; $this->CONDITION_RULE = unserialize(base64_decode($pr["CONDITION_RULE"])); $this->PRICE = $pr["PRICE"]; $this->XML_DATA = unserialize(base64_decode($pr["XML_DATA"])); $this->DATA_START = date("d-m-Y h:i:s", $pr["DATA_START"]); $this->PERIOD = (int) $pr["PERIOD"]; $this->USE_XML_FILE = $pr["USE_XML_FILE"] == "Y" ? true : false; $this->URL_DATA_FILE = $pr["URL_DATA_FILE"]; $this->NAMESCHEMA = $pr["NAMESCHEMA"]; $this->arSelect = array("ID", "CODE", "LID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID", "IBLOCK_CODE", "ACTIVE", "DATE_ACTIVE_FROM", "DATE_ACTIVE_TO", "SORT", "PREVIEW_PICTURE", "PREVIEW_TEXT", "TIMESTAMP_X", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DATE_CREATE", "CREATED_BY", "DETAIL_PAGE_URL"); $this->Filter = array("LID" => "", "IBLOCK_ID" => "", "SECTION_ID" => "", "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "INCLUDE_SUBSECTIONS" => "", "IBLOCK_ACTIVE" => "Y", "SECTION_GLOBAL_ACTIVE" => "Y"); if (is_array($this->GOOGLE_CATEGORY) && sizeof($this->GOOGLE_CATEGORY) > 0) { foreach ($this->GOOGLE_CATEGORY as $id => $gogle) { $this->GOOGLE_CATEGORY[$id]['THIS'] = text2xml($gogle['THIS'], true, true, $this->ENCODING); $this->GOOGLE_CATEGORY[$id]['GOOGLE'] = text2xml($gogle['GOOGLE'], false, true, $this->ENCODING); } } if ($this->isCat) { if (is_array($this->IBLOCK_ID)) { foreach ($this->IBLOCK_ID as $ibl) { $this->isCatalog[$ibl] = CCatalog::GetByID($ibl) ? true : false; } } else { $this->isCat = false; } } if ($this->isCat && (is_array($this->isCatalog) && sizeof($this->isCatalog) > 0)) { foreach ($this->isCatalog as $code => $val) { if ($val == 1) { $mxResult = CCatalogSKU::GetInfoByProductIBlock($code); if (is_array($mxResult)) { $this->sku_IBLOCK_ID[$code] = $mxResult['IBLOCK_ID']; $this->sku_PROPERTY[$code] = $mxResult['SKU_PROPERTY_ID']; } } } } if (CModule::IncludeModule("currency")) { $this->baseCur = CCurrency::GetbaseCurrency(); if ($this->baseCur == "RUB") { $this->baseCur = "RUB"; } } else { $this->baseCur = "RUB"; } $this->Filter['INCLUDE_SUBSECTIONS'] = $this->CHECK_INCLUDE ? "Y" : "N"; if (sizeof($this->IBLOCK_ID) > 0) { foreach ($this->IBLOCK_ID as $ibl) { $this->arFilter[$ibl] = $this->Filter; $this->arFilter[$ibl]["LID"] = $this->LID; $this->arFilter[$ibl]["IBLOCK_ID"] = $ibl; $this->arFilter[$ibl]["SECTION_ID"] = $this->GetSectionFromIB($ibl); } } if (sizeof($this->CONDITION_RULE) > 0) { $fltr = array(); $skufil = array(); $tmpFilter = array(); $tmpFilter1 = array(); foreach ($this->CONDITION_RULE as $al => $rule) { if ($al != "COUNT") { if ($rule['VALUE'] != "" && $rule['RULES'] != "no" && $rule['PROPERTY'] != 0 && !empty($rule['PROPERTY'])) { $tmp = explode("-", $rule['PROPERTY']); $tmp1 = explode("_", $tmp[1]); if (in_array("SKU", $tmp1)) { //add sku filter $skufil[$tmp[0]][] = array("PROPERTY" => $tmp1[1], "RULES" => $rule['RULES'], "VALUE" => $rule['VALUE']); } else { //add filter $fltr[$tmp[0]][] = array("PROPERTY" => $tmp[1], "RULES" => $rule['RULES'], "VALUE" => $rule['VALUE']); } } } } if (is_array($fltr) && sizeof($fltr) > 0) { $tmpFilter = $cgm->SQLCondition($fltr); } if (is_array($skufil) && sizeof($skufil) > 0) { $tmpFilter1 = $cgm->SQLCondition($skufil); } if (sizeof($this->IBLOCK_ID) > 0) { foreach ($this->IBLOCK_ID as $ibl) { if (sizeof($tmpFilter[$ibl]) > 0) { foreach ($tmpFilter[$ibl] as $cond) { foreach ($cond as $code => $cnd) { $this->EditFilter($ibl, $code, $cnd); } } } if (sizeof($tmpFilter1[$ibl]) > 0) { foreach ($tmpFilter1[$ibl] as $cond) { foreach ($cond as $code => $cnd) { $this->AddSkuFilter($ibl, $code, $cnd); } } } } } } if ($this->CHECK_INCLUDE) { foreach ($this->GOOGLE_CATEGORY as $id => $v) { $rsParentSection = CIBlockSection::GetByID($id); if ($arParentSection = $rsParentSection->GetNext()) { $arFilter = array('ACTIVE' => 'Y', 'IBLOCK_ID' => $arParentSection['IBLOCK_ID'], '>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'], '<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'], '>DEPTH_LEVEL' => $arParentSection['DEPTH_LEVEL']); $rsSect = CIBlockSection::GetList(array('left_margin' => 'asc'), $arFilter); while ($arSect = $rsSect->GetNext()) { $this->GOOGLE_CATEGORY[$arSect['ID']] = $v; } } } } unset($pro); }