Esempio n. 1
0
 /**
  * Returns map of properties to their types.
  * Properties of iblock and its sku returned
  * which marked as for smart filter.
  *
  * @return integer[]
  */
 private function getFilterProperty()
 {
     if (!isset($this->propertyFilter)) {
         $this->propertyFilter = array();
         $propertyList = \Bitrix\Iblock\SectionPropertyTable::getList(array("select" => array("PROPERTY_ID", "PROPERTY.PROPERTY_TYPE", "PROPERTY.USER_TYPE"), "filter" => array("=IBLOCK_ID" => array($this->facet->getIblockId(), $this->facet->getSkuIblockId()), "=SMART_FILTER" => "Y")));
         while ($link = $propertyList->fetch()) {
             if ($link["IBLOCK_SECTION_PROPERTY_PROPERTY_PROPERTY_TYPE"] === "N") {
                 $this->propertyFilter[$link["PROPERTY_ID"]] = Storage::NUMERIC;
             } elseif ($link["IBLOCK_SECTION_PROPERTY_PROPERTY_USER_TYPE"] === "DateTime") {
                 $this->propertyFilter[$link["PROPERTY_ID"]] = Storage::DATETIME;
             } elseif ($link["IBLOCK_SECTION_PROPERTY_PROPERTY_PROPERTY_TYPE"] === "S") {
                 $this->propertyFilter[$link["PROPERTY_ID"]] = Storage::STRING;
             } else {
                 $this->propertyFilter[$link["PROPERTY_ID"]] = Storage::DICTIONARY;
             }
         }
     }
     return $this->propertyFilter;
 }
Esempio n. 2
0
 public function fillItemPrices(&$resultItem, $arElement)
 {
     if (isset($arElement["MIN_VALUE_NUM"]) && isset($arElement["MAX_VALUE_NUM"])) {
         $currency = $arElement["VALUE"];
         $existCurrency = strlen($currency) > 0;
         if ($existCurrency) {
             $currency = $this->facet->lookupDictionaryValue($currency);
         }
         if ($this->convertCurrencyId && $existCurrency) {
             $priceValue = CCurrencyRates::ConvertCurrency($arElement["MIN_VALUE_NUM"], $currency, $this->convertCurrencyId);
         } else {
             $priceValue = $arElement["MIN_VALUE_NUM"];
         }
         if (!isset($resultItem["VALUES"]["MIN"]["VALUE"]) || $resultItem["VALUES"]["MIN"]["VALUE"] > $priceValue) {
             $resultItem["VALUES"]["MIN"]["VALUE"] = $priceValue;
             if ($existCurrency) {
                 $resultItem["VALUES"]["MIN"]["CURRENCY"] = $currency;
             }
         }
         if ($this->convertCurrencyId && $existCurrency) {
             $priceValue = CCurrencyRates::ConvertCurrency($arElement["MAX_VALUE_NUM"], $currency, $this->convertCurrencyId);
         } else {
             $priceValue = $arElement["MAX_VALUE_NUM"];
         }
         if (!isset($resultItem["VALUES"]["MAX"]["VALUE"]) || $resultItem["VALUES"]["MAX"]["VALUE"] < $priceValue) {
             $resultItem["VALUES"]["MAX"]["VALUE"] = $priceValue;
             if ($existCurrency) {
                 $resultItem["VALUES"]["MAX"]["CURRENCY"] = $currency;
             }
         }
     } else {
         $currency = $arElement["CATALOG_CURRENCY_" . $resultItem["ID"]];
         $existCurrency = strlen($currency) > 0;
         $price = $arElement["CATALOG_PRICE_" . $resultItem["ID"]];
         if (strlen($price)) {
             if ($this->convertCurrencyId && $existCurrency) {
                 $convertPrice = CCurrencyRates::ConvertCurrency($price, $currency, $this->convertCurrencyId);
             } else {
                 $convertPrice = (double) $price;
             }
             if (!isset($resultItem["VALUES"]["MIN"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MIN"]) || doubleval($resultItem["VALUES"]["MIN"]["VALUE"]) > $convertPrice) {
                 $resultItem["VALUES"]["MIN"]["VALUE"] = $price;
                 if ($existCurrency) {
                     $resultItem["VALUES"]["MIN"]["CURRENCY"] = $currency;
                 }
             }
             if (!isset($resultItem["VALUES"]["MAX"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MAX"]) || doubleval($resultItem["VALUES"]["MAX"]["VALUE"]) < $convertPrice) {
                 $resultItem["VALUES"]["MAX"]["VALUE"] = $price;
                 if ($existCurrency) {
                     $resultItem["VALUES"]["MAX"]["CURRENCY"] = $currency;
                 }
             }
         }
     }
     if ($existCurrency) {
         if ($this->convertCurrencyId) {
             $resultItem["CURRENCIES"][$this->convertCurrencyId] = isset($this->currencyCache[$this->convertCurrencyId]) ? $this->currencyCache[$this->convertCurrencyId] : $this->getCurrencyFullName($this->convertCurrencyId);
             $resultItem["~CURRENCIES"][$currency] = isset($this->currencyCache[$currency]) ? $this->currencyCache[$currency] : $this->getCurrencyFullName($currency);
         } else {
             $resultItem["CURRENCIES"][$currency] = isset($this->currencyCache[$currency]) ? $this->currencyCache[$currency] : $this->getCurrencyFullName($currency);
         }
     }
 }