Example #1
0
 static function productView($arResult, $user_id = false)
 {
     if ($arResult["ID"] != "") {
         $arResult["PRODUCT_ID"] = $arResult["ID"];
     }
     if (class_exists("DataManager")) {
         return false;
     }
     if (self::contains($_SERVER["HTTP_USER_AGENT"], "facebook.com")) {
         return;
     }
     $api_key = COption::GetOptionString(self::$MODULE_ID, "tracker_code", '');
     if (!$api_key) {
         return;
     }
     global $APPLICATION;
     global $USER;
     $visitor_uid = false;
     if (!$user_id) {
         $user_id = $USER->GetID();
     }
     $visitor_info = false;
     if ($user_id && ($visitor_info = self::getVisitorInfo($user_id))) {
         $visitor_uid = (int) $user_id;
     }
     $guest_uid = self::getUid($visitor_uid);
     $tracker = new ConveadTracker($api_key, SITE_SERVER_NAME, $guest_uid, $visitor_uid, $visitor_info, false, SITE_SERVER_NAME);
     $arProduct = CCatalogProduct::GetByIDEx($arResult["PRODUCT_ID"]);
     if ($arProduct && strpos($APPLICATION->GetCurPage(), $arProduct["DETAIL_PAGE_URL"]) !== false) {
         if (CCatalogSku::IsExistOffers($arResult["PRODUCT_ID"])) {
             $arOffers = CIBlockPriceTools::GetOffersArray(array("IBLOCK_ID" => $arProduct["IBLOCK_ID"]), array($arResult["PRODUCT_ID"]), array(), array("ID", "ACTIVE"));
             foreach ($arOffers as $array) {
                 if ($array["ACTIVE"] == "Y") {
                     $arResult["PRODUCT_ID"] = $array["ID"];
                     break;
                 }
             }
         }
         $_SESSION["CONVEAD_PRODUCT_ID"] = $arResult["PRODUCT_ID"];
         $_SESSION["CONVEAD_PRODUCT_NAME"] = str_replace("'", ''', $arProduct["NAME"]);
         $_SESSION["CONVEAD_PRODUCT_URL"] = "http://" . SITE_SERVER_NAME . $arProduct["DETAIL_PAGE_URL"];
         $product_id = $arResult["PRODUCT_ID"];
         $product_name = $arProduct["NAME"];
         $product_url = "http://" . SITE_SERVER_NAME . $arProduct["DETAIL_PAGE_URL"];
         if ($_SESSION["LAST_VIEW_ID"] == $arResult["PRODUCT_ID"]) {
             return false;
         } else {
             $_SESSION["LAST_VIEW_ID"] = $arResult["PRODUCT_ID"];
             return true;
         }
         //$result = $tracker->eventProductView($product_id, $product_name, $product_url);
         return true;
     }
 }
Example #2
0
 /**
  * Add offers for each catalog product.
  * @return void
  */
 protected function setItemsOffers()
 {
     // filter items to get only product type (not offers)
     $productIblocks = array();
     foreach ($this->data['CATALOG'] as $catalog) {
         if ($catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_FULL || $catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_PRODUCT) {
             $productIblocks[] = $catalog;
         }
     }
     // Get total offers for all catalog products
     foreach ($productIblocks as &$iblock) {
         if (empty($this->iblockItems[$iblock['IBLOCK_ID']])) {
             continue;
         }
         //if(empty($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]) || empty($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]))
         //	continue;
         if (!isset($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]) && !is_array($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']])) {
             $this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']] = array();
         }
         if (!isset($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]) && !is_array($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']])) {
             $this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']] = array();
         }
         $selectProperties = array_merge($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']], $this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]);
         $offers = CIBlockPriceTools::GetOffersArray(array('IBLOCK_ID' => $iblock['IBLOCK_ID'], 'HIDE_NOT_AVAILABLE' => $this->arParams['HIDE_NOT_AVAILABLE']), $this->iblockItems[$iblock['IBLOCK_ID']], array(), array("ID", "CODE", "NAME", "SORT", "PREVIEW_PICTURE", "DETAIL_PICTURE"), $selectProperties, $this->arParams["OFFERS_LIMIT"], $this->data['CATALOG_PRICES'], $this->arParams['PRICE_VAT_INCLUDE'], $this->data['CONVERT_CURRENCY']);
         if (empty($offers)) {
             continue;
         }
         foreach ($offers as &$offer) {
             $linkId = (int) $offer['LINK_ELEMENT_ID'];
             if (!isset($this->linkItems[$linkId])) {
                 continue;
             }
             $offer['~BUY_URL'] = $this->urlTemplates['~BUY_URL_TEMPLATE'] . $offer['ID'];
             $offer['BUY_URL'] = $this->urlTemplates['BUY_URL_TEMPLATE'] . $offer['ID'];
             $offer['~ADD_URL'] = $this->urlTemplates['~ADD_URL_TEMPLATE'] . $offer['ID'];
             $offer['ADD_URL'] = $this->urlTemplates['ADD_URL_TEMPLATE'] . $offer['ID'];
             $offer['~COMPARE_URL'] = $this->urlTemplates['~COMPARE_URL_TEMPLATE'] . $offer['ID'];
             $offer['COMPARE_URL'] = $this->urlTemplates['COMPARE_URL_TEMPLATE'] . $offer['ID'];
             $offer['~SUBSCRIBE_URL'] = $this->urlTemplates['~SUBSCRIBE_URL_TEMPLATE'] . $offer['ID'];
             $offer['SUBSCRIBE_URL'] = $this->urlTemplates['SUBSCRIBE_URL_TEMPLATE'] . $offer['ID'];
             if (!isset($this->linkItems[$linkId]['OFFERS'])) {
                 $this->linkItems[$linkId]['OFFERS'] = array();
             }
             $this->linkItems[$linkId]['OFFERS'][] = $offer;
         }
         unset($offer);
     }
     unset($iblock);
     // set selected flag
     foreach ($this->items as $key => &$item) {
         $index = 0;
         if (empty($item['OFFERS'])) {
             continue;
         }
         foreach ($item['OFFERS'] as $offerKey => &$offer) {
             $offer['SELECTED'] = $offer['ID'] == $key;
             if ($offer['SELECTED']) {
                 $index = $offerKey;
             }
         }
         $item['OFFERS_SELECTED'] = $index;
     }
     unset($item, $offer);
 }
if('Y' == $arCurrentValues['SHOW_SECTION_PICTURE']){
	$arTemplateParameters['SECTION_PICTURE_WIDTH'] = array(
		'PARENT' => 'LIST_SETTINGS',
		'NAME' => getMessage('RS_SLINE.SECTION_PICTURE_WIDTH'),
		'TYPE' => 'STRING',
		'DEFAULT' => '',
	);
	$arTemplateParameters['SECTION_PICTURE_HEIGHT'] = array(
		'PARENT' => 'LIST_SETTINGS',
		'NAME' => getMessage('RS_SLINE.SECTION_PICTURE_HEIGHT'),
		'TYPE' => 'STRING',
		'DEFAULT' => '',
	);
}

$arOffers = CIBlockPriceTools::GetOffersIBlock($IBLOCK_ID);
$OFFERS_IBLOCK_ID = is_array($arOffers) ? $arOffers['OFFERS_IBLOCK_ID']: 0;

if($OFFERS_IBLOCK_ID){
	$arProperty_Offers = array();
	$rsProp = CIBlockProperty::GetList(array('sort'=>'asc', 'name'=>'asc'), array('IBLOCK_ID'=>$OFFERS_IBLOCK_ID, 'ACTIVE'=>'Y'));
	while($arr=$rsProp->Fetch()){
		$arr['ID'] = intval($arr['ID']);
		if ($arOffers['OFFERS_PROPERTY_ID'] == $arr['ID'])
			continue;
		$strPropName = '['.$arr['ID'].']'.('' != $arr['CODE'] ? '['.$arr['CODE'].']' : '').' '.$arr['NAME'];
		if ('' == $arr['CODE'])
			$arr['CODE'] = $arr['ID'];
		$arProperty_Offers[$arr['CODE']] = $strPropName;
	}
Example #4
0
}
$arProperty_LINK = array();
if (0 < intval($arCurrentValues["LINK_IBLOCK_ID"])) {
    $rsProp = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("IBLOCK_ID" => $arCurrentValues["LINK_IBLOCK_ID"], 'PROPERTY_TYPE' => 'E', "ACTIVE" => "Y"));
    while ($arr = $rsProp->Fetch()) {
        $arProperty_LINK[$arr["CODE"]] = "[" . $arr["CODE"] . "] " . $arr["NAME"];
    }
}
$arUserFields_S = array("-" => " ");
$arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $arCurrentValues["IBLOCK_ID"] . "_SECTION");
foreach ($arUserFields as $FIELD_NAME => $arUserField) {
    if ($arUserField["USER_TYPE"]["BASE_TYPE"] == "string") {
        $arUserFields_S[$FIELD_NAME] = $arUserField["LIST_COLUMN_LABEL"] ? $arUserField["LIST_COLUMN_LABEL"] : $FIELD_NAME;
    }
}
$arOffers = CIBlockPriceTools::GetOffersIBlock($arCurrentValues["IBLOCK_ID"]);
$OFFERS_IBLOCK_ID = is_array($arOffers) ? $arOffers["OFFERS_IBLOCK_ID"] : 0;
$arProperty_Offers = array();
if ($OFFERS_IBLOCK_ID) {
    $rsProp = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("IBLOCK_ID" => $OFFERS_IBLOCK_ID, "ACTIVE" => "Y"));
    while ($arr = $rsProp->Fetch()) {
        if ($arr["PROPERTY_TYPE"] != "F") {
            $arProperty_Offers[$arr["CODE"]] = "[" . $arr["CODE"] . "] " . $arr["NAME"];
        }
    }
}
$arPrice = array();
if (CModule::IncludeModule("catalog")) {
    $rsPrice = CCatalogGroup::GetList($v1 = "sort", $v2 = "asc");
    while ($arr = $rsPrice->Fetch()) {
        $arPrice[$arr["NAME"]] = "[" . $arr["NAME"] . "] " . $arr["NAME_LANG"];
Example #5
0
 if (!isset($arParams["OFFERS_PROPERTY_CODE"])) {
     $arParams["OFFERS_PROPERTY_CODE"] = array();
 } elseif (!is_array($arParams["OFFERS_PROPERTY_CODE"])) {
     $arParams["OFFERS_PROPERTY_CODE"] = array($arParams["OFFERS_PROPERTY_CODE"]);
 }
 foreach ($arParams["OFFERS_PROPERTY_CODE"] as $key => $value) {
     if ($value === "") {
         unset($arParams["OFFERS_PROPERTY_CODE"][$key]);
     }
 }
 if ($bCatalog && !empty($arResult["ELEMENTS"]) && (!empty($arParams["OFFERS_FIELD_CODE"]) || !empty($arParams["OFFERS_PROPERTY_CODE"]))) {
     $offersFilter = array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'HIDE_NOT_AVAILABLE' => $arParams['HIDE_NOT_AVAILABLE']);
     if (!$arParams["USE_PRICE_COUNT"]) {
         $offersFilter['SHOW_PRICE_COUNT'] = $arParams['SHOW_PRICE_COUNT'];
     }
     $arOffers = CIBlockPriceTools::GetOffersArray($offersFilter, $arResult["ELEMENTS"], array($arParams["OFFERS_SORT_FIELD"] => $arParams["OFFERS_SORT_ORDER"], $arParams["OFFERS_SORT_FIELD2"] => $arParams["OFFERS_SORT_ORDER2"]), $arParams["OFFERS_FIELD_CODE"], $arParams["OFFERS_PROPERTY_CODE"], $arParams["OFFERS_LIMIT"], $arResult["PRICES"], $arParams['PRICE_VAT_INCLUDE'], $arConvertParams);
     if (!empty($arOffers)) {
         foreach ($arResult["ELEMENTS"] as $id) {
             $arElementLink[$id]['OFFERS'] = array();
         }
         unset($id);
         foreach ($arOffers as $arOffer) {
             if (isset($arElementLink[$arOffer["LINK_ELEMENT_ID"]])) {
                 $arOffer['~BUY_URL'] = str_replace('#ID#', $arOffer["ID"], $arResult['~BUY_URL_TEMPLATE']);
                 $arOffer['BUY_URL'] = str_replace('#ID#', $arOffer["ID"], $arResult['BUY_URL_TEMPLATE']);
                 $arOffer['~ADD_URL'] = str_replace('#ID#', $arOffer["ID"], $arResult['~ADD_URL_TEMPLATE']);
                 $arOffer['ADD_URL'] = str_replace('#ID#', $arOffer["ID"], $arResult['ADD_URL_TEMPLATE']);
                 if ($arParams['DISPLAY_COMPARE']) {
                     $arOffer['~COMPARE_URL'] = str_replace('#ID#', $arOffer["ID"], $arResult['~COMPARE_URL_TEMPLATE']);
                     $arOffer['COMPARE_URL'] = str_replace('#ID#', $arOffer["ID"], $arResult['COMPARE_URL_TEMPLATE']);
                 }
Example #6
0
			{
				if ($arPrice['MIN_PRICE'] == "Y")
				{
					$arItem["PRICE_CURRENCY"] = $arPrice["CURRENCY"];
					$arItem["PRICE_DISCOUNT_VALUE"] = $arPrice["DISCOUNT_VALUE"];
					$arItem["PRICE_PRINT_DISCOUNT_VALUE"] = $arPrice["PRINT_DISCOUNT_VALUE"];
					$arItem["PRICE_VALUE"] = $arPrice["VALUE"];
					$arItem["PRICE_PRINT_VALUE"] = $arPrice["PRINT_VALUE"];
					$arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"] = $arPrice["DISCOUNT_DIFF"];
					$arItem["PRICE_DISCOUNT_DIFFERENCE"] = $arPrice["PRINT_DISCOUNT_DIFF"];
					$arItem["PRICE_DISCOUNT_PERCENT"] = $arPrice["DISCOUNT_DIFF_PERCENT"];
					break;
				}
			}

			$arItem["CAN_BUY"] = CIBlockPriceTools::CanBuy($arItem["IBLOCK_ID"], $arResult["PRICES"], $arItem);
		}

		if (defined("BX_COMP_MANAGED_CACHE"))
		{
			$CACHE_MANAGER->RegisterTag("iblock_id_".$arItem['IBLOCK_ID']);
		}

		if ($arItem["ID"] == $elementID)
		{
			$arResult["ELEMENT"] = $arItem;

			$arResult["SET_ITEMS"]["PRICE"] += $arItem["PRICE_DISCOUNT_VALUE"];
			$arResult["SET_ITEMS"]["OLD_PRICE"] += $arItem["PRICE_VALUE"];
			$arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] += $arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"];
		}
Example #7
0
			'SLIDER_COUNT' => $arOffer['MORE_PHOTO_COUNT'],
			'BUY_URL' => $arOffer['~BUY_URL']
		);
		$arMatrix[$keyOffer] = $arOneRow;
	}
	if (-1 == $intSelected)
		$intSelected = 0;
	$arResult['JS_OFFERS'] = $arMatrix;
	$arResult['OFFERS_SELECTED'] = $intSelected;

	$arResult['OFFERS_IBLOCK'] = $arSKU['IBLOCK_ID'];
}

if ($arResult['MODULES']['catalog'] && $arResult['CATALOG'] && CCatalogProduct::TYPE_PRODUCT == $arResult['CATALOG_TYPE'])
{
	CIBlockPriceTools::setRatioMinPrice($arResult, true);
}

if (!empty($arResult['DISPLAY_PROPERTIES']))
{
	foreach ($arResult['DISPLAY_PROPERTIES'] as $propKey => $arDispProp)
	{
		if ('F' == $arDispProp['PROPERTY_TYPE'])
			unset($arResult['DISPLAY_PROPERTIES'][$propKey]);
	}
}

$arResult['SKU_PROPS'] = $arSKUPropList;
$arResult['DEFAULT_PICTURE'] = $arEmptyPreview;

$arResult['wish']['isWished'] = CIBlockElement::GetList(false, array(
Example #8
0
				$arItem['MIN_PRICE'] = CIBlockPriceTools::getMinPriceFromOffers(
					$arItem['OFFERS'],
					$boolConvert ? $arResult['CONVERT_CURRENCY']['CURRENCY_ID'] : $strBaseCurrency
				);
			}
		}

		if (
			$arResult['MODULES']['catalog']
			&& $arItem['CATALOG']
			&&
				($arItem['CATALOG_TYPE'] == CCatalogProduct::TYPE_PRODUCT
				|| $arItem['CATALOG_TYPE'] == CCatalogProduct::TYPE_SET)
		)
		{
			CIBlockPriceTools::setRatioMinPrice($arItem, false);
			$arItem['MIN_BASIS_PRICE'] = $arItem['MIN_PRICE'];
		}

		if (!empty($arItem['DISPLAY_PROPERTIES']))
		{
			foreach ($arItem['DISPLAY_PROPERTIES'] as $propKey => $arDispProp)
			{
				if ('F' == $arDispProp['PROPERTY_TYPE'])
					unset($arItem['DISPLAY_PROPERTIES'][$propKey]);
			}
		}
		$arItem['LAST_ELEMENT'] = 'N';
		$arNewItemsList[$key] = $arItem;
	}
	$arNewItemsList[$key]['LAST_ELEMENT'] = 'Y';
Example #9
0
 $arIblockOfferProps = array();
 $arIblockOfferPropsFilter = array();
 foreach ($arIblockOfferPropsFilter as $val) {
     $arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
     $arIblockOfferPropsFilter[] = $val["CODE"];
 }
 static $arCacheResultPrices = array();
 if (!is_set($arCacheResultPrices[$arElements["IBLOCK_ID"]])) {
     $dbPriceType = CCatalogGroup::GetList(array(), array('NAME_LANG' => $arItems['NOTES'], 'CAN_BUY' => 'Y'), false, false, array('NAME', 'ID'));
     $arPriceType = $dbPriceType->Fetch();
     $arResultPrices = CIBlockPriceTools::GetCatalogPrices($arElements["IBLOCK_ID"], array($arPriceType["NAME"]));
     $arCacheResultPrices[$arElements["IBLOCK_ID"]] = $arResultPrices;
 } else {
     $arResultPrices = $arCacheResultPrices[$arElements["IBLOCK_ID"]];
 }
 $arOffers = CIBlockPriceTools::GetOffersArray($arElements["IBLOCK_ID"], $arItems["PRODUCT_ID"], array("ID" => "DESC"), array("NAME"), $arIblockOfferPropsFilter, 0, $arResultPrices, 1, array(), $USER->GetID(), $arItems['LID']);
 if (count($arOffers) > 0) {
     foreach ($arOffers as $arOffer) {
         /*$arPrice = CCatalogProduct::GetOptimalPrice($arOffer['ID'], 1, $arGroups, "N", array(), $arItems['LID']);
         					$arOffer["PRICES"] = $arPrice;
         
         					if ($arCatalogProduct = CCatalogProduct::GetByID($arOffer['ID']))
         					{
         						if ($arCatalogProduct["CAN_BUY_ZERO"]!="Y" && ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && doubleval($arCatalogProduct["QUANTITY"])<=0))
         							$arItems["CAN_BUY"] = "N";
         						else
         							$arItems["CAN_BUY"] = "Y";
         					}
         
         					if (($priceMin === 0) || ($arPrice["DISCOUNT_PRICE"] < $priceMin))
         						$priceMin = $arPrice["DISCOUNT_PRICE"];*/
Example #10
0
    }
}
if (!empty($arCurrentValues['IBLOCK_ID'])) {
    $arIBlocks = $arCurrentValues['IBLOCK_ID'];
} else {
    $rsIBlock = CIBlock::GetList(array("sort" => "asc"), array("TYPE" => $arCurrentValues["IBLOCK_TYPE_ID"], "ACTIVE" => "Y"));
    while ($arr = $rsIBlock->Fetch()) {
        $arIBlocks = $arr["ID"];
    }
}
if (!empty($arIBlocks)) {
    $arProperty_Offers = array();
    //foreach ($arIBlocks as $intIBlockID)
    //{
    if (intval($arIBlocks) > 0) {
        $arOffers = CIBlockPriceTools::GetOffersIBlock($arIBlocks);
        $OFFERS_IBLOCK_ID = is_array($arOffers) ? $arOffers["OFFERS_IBLOCK_ID"] : 0;
        if ($OFFERS_IBLOCK_ID) {
            $OFFERS_IBLOCK_ID2 = true;
            $rsProp = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("ACTIVE" => "Y", "IBLOCK_ID" => $OFFERS_IBLOCK_ID));
            while ($arr = $rsProp->Fetch()) {
                if ($arr["PROPERTY_TYPE"] != "F") {
                    $arProperty_Offers[$arr["CODE"]] = "[" . $arr["CODE"] . "] " . $arr["NAME"];
                }
            }
        }
    }
    //}
}
$arPrice = array();
if (CModule::IncludeModule("catalog")) {
Example #11
0
	public static function getMinPriceFromOffers(&$offers, $currency)
	{
		$result = false;
		$minPrice = 0;
		if (!empty($offers) && is_array($offers))
		{
			$doubles = array();
			foreach ($offers as $oneOffer)
			{
				$oneOffer['ID'] = intval($oneOffer['ID']);
				if (isset($doubles[$oneOffer['ID']]))
					continue;
				if (!$oneOffer['CAN_BUY'])
					continue;

				CIBlockPriceTools::setRatioMinPrice($oneOffer, true);

				$oneOffer['MIN_PRICE']['CATALOG_MEASURE_RATIO'] = $oneOffer['CATALOG_MEASURE_RATIO'];
				$oneOffer['MIN_PRICE']['CATALOG_MEASURE'] = $oneOffer['CATALOG_MEASURE'];
				$oneOffer['MIN_PRICE']['CATALOG_MEASURE_NAME'] = $oneOffer['CATALOG_MEASURE_NAME'];
				$oneOffer['MIN_PRICE']['~CATALOG_MEASURE_NAME'] = $oneOffer['~CATALOG_MEASURE_NAME'];

				if (empty($result))
				{
					$minPrice = ($oneOffer['MIN_PRICE']['CURRENCY'] == $currency
						? $oneOffer['MIN_PRICE']['DISCOUNT_VALUE']
						: CCurrencyRates::ConvertCurrency($oneOffer['MIN_PRICE']['DISCOUNT_VALUE'], $oneOffer['MIN_PRICE']['CURRENCY'], $currency)
					);
					$result = $oneOffer['MIN_PRICE'];
				}
				else
				{
					$comparePrice = ($oneOffer['MIN_PRICE']['CURRENCY'] == $currency
						? $oneOffer['MIN_PRICE']['DISCOUNT_VALUE']
						: CCurrencyRates::ConvertCurrency($oneOffer['MIN_PRICE']['DISCOUNT_VALUE'], $oneOffer['MIN_PRICE']['CURRENCY'], $currency)
					);
					if ($minPrice > $comparePrice)
					{
						$minPrice = $comparePrice;
						$result = $oneOffer['MIN_PRICE'];
					}
				}
				$doubles[$oneOffer['ID']] = true;
			}
		}
		return $result;
	}
                 $arFields = $obEl->GetFields();
                 if (!empty($arFields["IBLOCK_SECTION_ID"])) {
                     $arSec = $arSect;
                 }
                 $path = !empty($arFields['DETAIL_PICTURE']) ? $arFields['DETAIL_PICTURE'] : $arFields['PREVIEW_PICTURE'];
                 if (empty($path)) {
                     $arProp = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], array(), array('CODE' => 'MORE_PHOTO'))->Fetch();
                     $path = $arProp["VALUE"];
                 }
                 $path = CFile::ResizeImageGet($path, array('width' => 150, 'height' => 150), BX_RESIZE_IMAGE_PROPORTIONAL, false);
                 $path = $path['src'];
                 if (CModule::IncludeModule('catalog')) {
                     $arResultPrices = CIBlockPriceTools::GetCatalogPrices($arFields["IBLOCK_ID"], array($arParams["PRICE_CODE"]));
                     $arProduct = CCatalogProduct::GetByID($arFields["ID"]);
                     $arProduct['VAT_INCLUDED'] = $arProduct['VAT_INCLUDED'] == 'Y' ? true : false;
                     $arPrices = CIBlockPriceTools::GetItemPrices($arFields["IBLOCK_ID"], $arResultPrices, $arFields, $arProduct['VAT_INCLUDED'], array("CURRENCY_ID" => $arParams["CURRENCY"]));
                 }
                 $arHits[$index][] = array("NAME" => $arFields["NAME"], "SECTION" => $arSec["NAME"], "SECTION_PAGE_URL" => $arSec["SECTION_PAGE_URL"], "DETAIL_PAGE_URL" => $arFields["DETAIL_PAGE_URL"], "PHOTO" => $path, "PRICE" => $arPrices, "SALELEADER" => $arFields["PROPERTY_SALELEADER_VALUE"], "NEWPRODUCT" => $arFields["PROPERTY_NEWPRODUCT_VALUE"], "SPECIAL_OFFER" => $arFields["PROPERTY_SPECIAL_OFFER_VALUE"]);
             }
             // while( $obEl = $dbRes->GetNextElement() )
             $arResult['HITS'][$index] = $arHits[$index];
         }
         // if($arParams["VIEW_HIT"] == "Y" && $arItem['DEPTH_LEVEL'] == 1)
     }
     // foreach($arResult as &$arItem => $index)
     if ($obCache->StartDataCache($life_time, $cache_id, "/")) {
         $obCache->EndDataCache(array("MENU_HITS" => $arHits));
     }
 }
 // if(!is_array($arResult['HITS']))
 unset($obCache);
Example #13
0
	public static function GetOffersArray($IBLOCK_ID, $arElementID, $arOrder, $arSelectFields, $arSelectProperties, $limit, $arPrices, $vat_include, $arCurrencyParams = array(), $USER_ID = 0, $LID = SITE_ID)
	{
		$arResult = array();

		$arOffersIBlock = CIBlockPriceTools::GetOffersIBlock($IBLOCK_ID);
		if($arOffersIBlock)
		{
			$limit = intval($limit);
			if (0 > $limit)
				$limit = 0;

			if(!array_key_exists("ID", $arOrder))
				$arOrder["ID"] = "DESC";

			$arFilter = array(
				"IBLOCK_ID" => $arOffersIBlock["OFFERS_IBLOCK_ID"],
				"PROPERTY_".$arOffersIBlock["OFFERS_PROPERTY_ID"] => $arElementID,
				"ACTIVE" => "Y",
				"ACTIVE_DATE" => "Y",
			);

			$arSelect = array(
				"ID" => 1,
				"IBLOCK_ID" => 1,
				"PROPERTY_".$arOffersIBlock["OFFERS_PROPERTY_ID"] => 1,
			);
			//if(!$arParams["USE_PRICE_COUNT"])
			{
				foreach($arPrices as $value)
				{
					$arSelect[$value["SELECT"]] = 1;
					//$arrFilter["CATALOG_SHOP_QUANTITY_".$value["ID"]] = $arParams["SHOW_PRICE_COUNT"];
				}
			}

			foreach($arSelectFields as $code)
				$arSelect[$code] = 1; //mark to select

			$arOffersPerElement = array();
			$rsOffers = CIBlockElement::GetList($arOrder, $arFilter, false, false, array_keys($arSelect));
			while($obOffer = $rsOffers->GetNextElement())
			{
				$arOffer = $obOffer->GetFields();
				$element_id = $arOffer["PROPERTY_".$arOffersIBlock["OFFERS_PROPERTY_ID"]."_VALUE"];
				//No more than limit offers per element
				if($limit > 0)
				{
					$arOffersPerElement[$element_id]++;
					if($arOffersPerElement[$element_id] > $limit)
						continue;
				}

				if($element_id > 0)
				{
					$arOffer["LINK_ELEMENT_ID"] = $element_id;
					$arOffer["DISPLAY_PROPERTIES"] = array();
					if(!empty($arSelectProperties))
					{
						$arOffer["PROPERTIES"] = $obOffer->GetProperties();
						foreach($arSelectProperties as $pid)
						{
							$prop = &$arOffer["PROPERTIES"][$pid];
							if((is_array($prop["VALUE"]) && count($prop["VALUE"])>0) ||
							(!is_array($prop["VALUE"]) && strlen($prop["VALUE"])>0))
							{
								$arOffer["DISPLAY_PROPERTIES"][$pid] = CIBlockFormatProperties::GetDisplayValue($arOffer, $prop, "catalog_out");
							}
						}
					}

					$arOffer["PRICES"] = CIBlockPriceTools::GetItemPrices($arOffersIBlock["OFFERS_IBLOCK_ID"], $arPrices, $arOffer, $vat_include, $arCurrencyParams, $USER_ID, $LID);
					$arOffer["CAN_BUY"] = CIBlockPriceTools::CanBuy($arOffersIBlock["OFFERS_IBLOCK_ID"], $arPrices, $arOffer);
				}
				$arResult[] = $arOffer;
			}
		}

		return $arResult;
	}
Example #14
0
 $arProps = array();
 if (strpos($newProductId['XML_ID'], '#') === false) {
     $parentIterator = \Bitrix\Iblock\ElementTable::getList(array('select' => array('ID', 'XML_ID'), 'filter' => array('ID' => $parentId)));
     if ($parentProduct = $parentIterator->fetch()) {
         $newProductId['XML_ID'] = $parentProduct['XML_ID'] . '#' . $newProductId['XML_ID'];
     }
     unset($parentProduct, $parentIterator);
 }
 $arFields["PRODUCT_XML_ID"] = $newProductId['XML_ID'];
 $propertyIterator = \Bitrix\Iblock\PropertyTable::getList(array('select' => array('ID', 'CODE'), 'filter' => array('IBLOCK_ID' => $newProductId['IBLOCK_ID'], '!ID' => $sku['SKU_PROPERTY_ID'])));
 while ($property = $propertyIterator->fetch()) {
     $property['CODE'] = (string) $property['CODE'];
     $arPropsSku[] = $property['CODE'] != '' ? $property['CODE'] : $property['ID'];
 }
 unset($property, $propertyIterator);
 $product_properties = CIBlockPriceTools::GetOfferProperties($newProductId['ID'], $sku['PRODUCT_IBLOCK_ID'], $arPropsSku);
 $newValues = array();
 foreach ($product_properties as $productSkuProp) {
     $bFieldExists = false;
     foreach ($strOffersProps as $existingSkuProp) {
         if ($existingSkuProp == $productSkuProp["CODE"]) {
             $bFieldExists = true;
             break;
         }
     }
     if ($bFieldExists === true) {
         $newValues[] = array("NAME" => $productSkuProp["NAME"], "CODE" => $productSkuProp["CODE"], "VALUE" => $productSkuProp["VALUE"], "SORT" => $productSkuProp["SORT"]);
     }
 }
 $newValues[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $newProductId["XML_ID"]);
 $arFields['PROPS'] = isset($arItem['PROPS']) ? updateBasketOffersProps($arItem['PROPS'], $newValues) : $newValues;
Example #15
0
 /**
  * Add offers for each catalog product.
  * @return void
  */
 protected function setItemsOffers()
 {
     global $APPLICATION;
     // filter items to get only product type (not offers)
     $fullProductIds = array();
     //
     $productIblocks = array();
     foreach ($this->data['CATALOG'] as $catalog) {
         if ($catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_FULL) {
             $productIblocks[] = $catalog;
             foreach ($this->items as $item) {
                 if ($item['IBLOCK_ID'] == $catalog['IBLOCK_ID']) {
                     $fullProductIds[] = $item['ID'];
                 }
             }
         }
     }
     if (empty($fullProductIds)) {
         return;
     }
     $fullProductIds = array_unique($fullProductIds);
     // Get total offers for all catalog products
     $totalOffers = array();
     foreach ($productIblocks as $iblock) {
         //if(empty($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]) || empty($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]))
         //	continue;
         if (!isset($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]) && !is_array($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']])) {
             $this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']] = array();
         }
         if (!isset($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]) && !is_array($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']])) {
             $this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']] = array();
         }
         $selectProperties = array_merge($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']], $this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]);
         $offers = CIBlockPriceTools::GetOffersArray(array('IBLOCK_ID' => $iblock['IBLOCK_ID'], 'HIDE_NOT_AVAILABLE' => $this->arParams['HIDE_NOT_AVAILABLE']), $fullProductIds, array(), array("ID", "CODE", "NAME", "SORT", "PREVIEW_PICTURE", "DETAIL_PICTURE"), $selectProperties, $this->arParams["OFFERS_LIMIT"], $this->data['CATALOG_PRICES'], $this->arParams['PRICE_VAT_INCLUDE'], $this->data['CONVERT_CURRENCY']);
         $totalOffers = array_merge($totalOffers, $offers);
     }
     if (empty($totalOffers)) {
         return;
     }
     foreach ($totalOffers as $offer) {
         $offer["~BUY_URL"] = $APPLICATION->GetCurPageParam($this->arParams["ACTION_VARIABLE"] . "=BUY&" . $this->arParams["PRODUCT_ID_VARIABLE"] . "=" . $offer["ID"], array($this->arParams["PRODUCT_ID_VARIABLE"], $this->arParams["ACTION_VARIABLE"]));
         $offer["BUY_URL"] = htmlspecialcharsbx($offer["~BUY_URL"]);
         $offer["~ADD_URL"] = $APPLICATION->GetCurPageParam($this->arParams["ACTION_VARIABLE"] . "=ADD2BASKET&" . $this->arParams["PRODUCT_ID_VARIABLE"] . "=" . $offer["ID"], array($this->arParams["PRODUCT_ID_VARIABLE"], $this->arParams["ACTION_VARIABLE"]));
         $offer["ADD_URL"] = htmlspecialcharsbx($offer["~ADD_URL"]);
         $offer["~COMPARE_URL"] = $APPLICATION->GetCurPageParam("action=ADD_TO_COMPARE_LIST&id=" . $offer["ID"], array($this->arParams["PRODUCT_ID_VARIABLE"], $this->arParams["ACTION_VARIABLE"]));
         $offer["COMPARE_URL"] = htmlspecialcharsbx($offer["~COMPARE_URL"]);
         $offer["~SUBSCRIBE_URL"] = $APPLICATION->GetCurPageParam($this->arParams["ACTION_VARIABLE"] . "=SUBSCRIBE_PRODUCT&id=" . $offer["ID"], array($this->arParams["PRODUCT_ID_VARIABLE"], $this->arParams["ACTION_VARIABLE"]));
         $offer["SUBSCRIBE_URL"] = htmlspecialcharsbx($offer["~SUBSCRIBE_URL"]);
         $linkId = (int) $offer['LINK_ELEMENT_ID'];
         foreach ($this->items as &$item) {
             if (!isset($item['OFFERS'])) {
                 $item['OFFERS'] = array();
             }
             if ($linkId == $item['ID']) {
                 $item['OFFERS'][] = $offer;
             }
         }
         unset($item);
     }
     // set selected flag
     foreach ($this->items as $key => &$item) {
         $index = 0;
         foreach ($item['OFFERS'] as $offerKey => &$offer) {
             $offer['SELECTED'] = $offer['ID'] == $key;
             if ($offer['SELECTED']) {
                 $index = $offerKey;
             }
         }
         $item['OFFERS_SELECTED'] = $index;
     }
     unset($item);
     unset($offer);
 }
Example #16
0
}
if (isset($_REQUEST["id"])) {
    $id = intval($_REQUEST["id"]);
} else {
    $id = 0;
}
/*************************************************************************
			Handling the Compare button
*************************************************************************/
if ($_REQUEST["action"] == "ADD_TO_COMPARE_LIST" && $id > 0) {
    if (!array_key_exists($id, $_SESSION[$arParams["NAME"]][$arParams["IBLOCK_ID"]]["ITEMS"])) {
        //SELECT
        $arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "DETAIL_PAGE_URL");
        //WHERE
        $arFilter = array("ID" => $id, "IBLOCK_LID" => SITE_ID, "IBLOCK_ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y");
        $arOffers = CIBlockPriceTools::GetOffersIBlock($arParams["IBLOCK_ID"]);
        $OFFERS_IBLOCK_ID = $arOffers ? $arOffers["OFFERS_IBLOCK_ID"] : 0;
        if ($arOffers) {
            $arFilter["IBLOCK_ID"] = array($arParams["IBLOCK_ID"], $arOffers["OFFERS_IBLOCK_ID"]);
        } else {
            $arFilter["IBLOCK_ID"] = $arParams["IBLOCK_ID"];
        }
        $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
        $rsElement->SetUrlTemplates($arParams["DETAIL_URL"]);
        $arElement = $rsElement->GetNext();
        $arMaster = false;
        if ($arElement && $arElement["IBLOCK_ID"] == $OFFERS_IBLOCK_ID) {
            $rsMasterProperty = CIBlockElement::GetProperty($arElement["IBLOCK_ID"], $arElement["ID"], array(), array("ID" => $arOffers["OFFERS_PROPERTY_ID"], "EMPTY" => "N"));
            if ($arMasterProperty = $rsMasterProperty->Fetch()) {
                $rsMaster = CIBlockElement::GetList(array(), array("ID" => $arMasterProperty["VALUE"], "IBLOCK_ID" => $arMasterProperty["LINK_IBLOCK_ID"], "ACTIVE" => "Y"), false, false, $arSelect);
                $rsMaster->SetUrlTemplates($arParams["DETAIL_URL"]);
Example #17
0
    $obParser = new CTextParser();
    if (is_array($arParams["PRICE_CODE"])) {
        $arResult["PRICES"] = CIBlockPriceTools::GetCatalogPrices(0, $arParams["PRICE_CODE"]);
    } else {
        $arResult["PRICES"] = array();
    }
    $arSelect = array("ID", "IBLOCK_ID", "PREVIEW_TEXT", "PREVIEW_PICTURE", "DETAIL_PICTURE");
    $arFilter = array("IBLOCK_LID" => SITE_ID, "IBLOCK_ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R");
    foreach ($arResult["PRICES"] as $value) {
        $arSelect[] = $value["SELECT"];
        $arFilter["CATALOG_SHOP_QUANTITY_" . $value["ID"]] = 1;
    }
    $arFilter["=ID"] = $arResult["ELEMENTS"];
    $rsElements = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
    while ($arElement = $rsElements->Fetch()) {
        $arElement["PRICES"] = CIBlockPriceTools::GetItemPrices($arElement["IBLOCK_ID"], $arResult["PRICES"], $arElement, $arParams['PRICE_VAT_INCLUDE'], $arConvertParams);
        if ($arParams["PREVIEW_TRUNCATE_LEN"] > 0) {
            $arElement["PREVIEW_TEXT"] = $obParser->html_cut($arElement["PREVIEW_TEXT"], $arParams["PREVIEW_TRUNCATE_LEN"]);
        }
        $arResult["ELEMENTS"][$arElement["ID"]] = $arElement;
    }
}
foreach ($arResult["SEARCH"] as $i => $arItem) {
    switch ($arItem["MODULE_ID"]) {
        case "iblock":
            if (array_key_exists($arItem["ITEM_ID"], $arResult["ELEMENTS"])) {
                $arElement =& $arResult["ELEMENTS"][$arItem["ITEM_ID"]];
                if ($arParams["SHOW_PREVIEW"] == "Y") {
                    if ($arElement["PREVIEW_PICTURE"] > 0) {
                        $arElement["PICTURE"] = CFile::ResizeImageGet($arElement["PREVIEW_PICTURE"], array("width" => $PREVIEW_WIDTH, "height" => $PREVIEW_HEIGHT), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                    } elseif ($arElement["DETAIL_PICTURE"] > 0) {
Example #18
0
<?php

define("NOT_CHECK_PERMISSIONS", true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
if (!CModule::IncludeModule("catalog")) {
    return;
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["action"]) > 0 && check_bitrix_sessid()) {
    $APPLICATION->RestartBuffer();
    switch ($_POST["action"]) {
        case "catalogSetAdd2Basket":
            if (is_array($_POST["set_ids"])) {
                foreach ($_POST["set_ids"] as $itemID) {
                    $product_properties = true;
                    if (!empty($_POST["setOffersCartProps"])) {
                        $product_properties = CIBlockPriceTools::GetOfferProperties($itemID, $_POST["iblockId"], $_POST["setOffersCartProps"]);
                    }
                    $ratio = 1;
                    if ($_POST["itemsRatio"][$itemID]) {
                        $ratio = $_POST["itemsRatio"][$itemID];
                    }
                    if (intval($itemID)) {
                        Add2BasketByProductID(intval($itemID), $ratio, array("LID" => $_POST["lid"]), $product_properties);
                    }
                }
            }
            break;
        case "ajax_recount_prices":
            if (strlen($_POST["currency"]) > 0) {
                $arPices = array("formatSum" => "", "formatOldSum" => "", "formatDiscDiffSum" => "");
                if ($_POST["sumPrice"]) {
/**
 * @param $userId
 * @param $lid
 * @param $productId
 * @param string $productName
 * @param string $currency
 * @param array $arProduct
 * @return array|bool
 */
function GetProductSku($userId, $lid, $productId, $productName = '', $currency = '', $arProduct = array())
{
    $userId = intval($userId);
    $productId = intval($productId);
    if ($productId <= 0) {
        return false;
    }
    $lid = trim($lid);
    if (strlen($lid) <= 0) {
        return false;
    }
    $productName = trim($productName);
    $arResult = array();
    static $arCacheGroups = array();
    if (!isset($arCacheGroups[$userId])) {
        $arCacheGroups[$userId] = CUser::GetUserGroup($userId);
    }
    $arGroups = $arCacheGroups[$userId];
    if (!isset($arProduct["IBLOCK_ID"]) || 0 >= intval($arProduct["IBLOCK_ID"])) {
        $arProduct["IBLOCK_ID"] = CIBlockElement::GetIBlockByID($arProduct["IBLOCK_ID"]);
    }
    static $arOffersIblock = array();
    if (!isset($arOffersIblock[$arProduct["IBLOCK_ID"]])) {
        $mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]);
        if (is_array($mxResult)) {
            $arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"];
        }
    }
    if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0) {
        static $arCacheOfferProperties = array();
        if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]])) {
            $dbOfferProperties = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $arOffersIblock[$arProduct["IBLOCK_ID"]], 'ACTIVE' => 'Y', "!XML_ID" => "CML2_LINK"));
            while ($arOfferProperties = $dbOfferProperties->Fetch()) {
                if ('F' == $arOfferProperties['PROPERTY_TYPE']) {
                    continue;
                }
                $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties;
            }
        }
        $arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]];
        $arIblockOfferProps = array();
        $arIblockOfferPropsFilter = array();
        if (is_array($arOfferProperties)) {
            foreach ($arOfferProperties as $val) {
                $arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
                $arIblockOfferPropsFilter[] = $val["CODE"];
            }
        }
        $arOffers = CIBlockPriceTools::GetOffersArray($arProduct["IBLOCK_ID"], $productId, array("ID" => "DESC"), array("NAME", "EXTERNAL_ID"), $arIblockOfferPropsFilter, 0, array(), 1, array(), $userId, $lid);
        $arSku = array();
        $arSkuId = array();
        $arImgSku = array();
        foreach ($arOffers as $arOffer) {
            $arSkuId[] = $arOffer['ID'];
        }
        if (!empty($arSkuId)) {
            $res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL", "ACTIVE"));
            while ($arOfferImg = $res->GetNext()) {
                $arImgSku[$arOfferImg["ID"]] = $arOfferImg;
            }
        }
        $arOffersId = array();
        foreach ($arOffers as $arOffer) {
            $arOffersId[] = $arOffer['ID'];
        }
        $dbCatalogProduct = CCatalogProduct::GetList(array(), array("ID" => $arOffersId));
        while ($arCatalogProduct = $dbCatalogProduct->fetch()) {
            $arCatalogProductResult[$arCatalogProduct["ID"]] = $arCatalogProduct;
        }
        foreach ($arOffers as $arOffer) {
            $arSkuTmp = array();
            $active = '';
            $arOffer["CAN_BUY"] = "N";
            $arCatalogProduct = $arCatalogProductResult[$arOffer["ID"]];
            if (!empty($arCatalogProduct)) {
                if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
                    $arOffer["CAN_BUY"] = "N";
                } else {
                    $arOffer["CAN_BUY"] = "Y";
                }
            }
            $arSkuTmp["ImageUrl"] = '';
            if ($arOffer["CAN_BUY"] == "Y") {
                if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']])) {
                    if ('' == $productName) {
                        $productName = $arImgSku[$arOffer['ID']]["~NAME"];
                    }
                    $active = $arImgSku[$arOffer['ID']]["ACTIVE"];
                    if ($arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"] != "") {
                        $arSkuTmp["PREVIEW_PICTURE"] = $arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"];
                    }
                    if ($arImgSku[$arOffer['ID']]["DETAIL_PICTURE"] != "") {
                        $arSkuTmp["DETAIL_PICTURE"] = $arImgSku[$arOffer['ID']]["DETAIL_PICTURE"];
                    }
                }
            }
            foreach ($arIblockOfferProps as $arCode) {
                if (is_array($arCode) && isset($arOffer["PROPERTIES"][$arCode["CODE"]])) {
                    if (isset($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]])) {
                        $mxValues = '';
                        if ('E' == $arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['PROPERTY_TYPE']) {
                            if (!empty($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_ELEMENT_VALUE'])) {
                                $mxValues = array();
                                foreach ($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_ELEMENT_VALUE'] as $arTempo) {
                                    $mxValues[] = $arTempo['NAME'] . ' [' . $arTempo['ID'] . ']';
                                }
                            }
                        } elseif ('G' == $arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['PROPERTY_TYPE']) {
                            if (!empty($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_SECTION_VALUE'])) {
                                $mxValues = array();
                                foreach ($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_SECTION_VALUE'] as $arTempo) {
                                    $mxValues[] = $arTempo['NAME'] . ' [' . $arTempo['ID'] . ']';
                                }
                            }
                        }
                        if (empty($mxValues)) {
                            $mxValues = $arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]["DISPLAY_VALUE"];
                        }
                        $arSkuTmp[] = strip_tags(is_array($mxValues) ? implode("/ ", $mxValues) : $mxValues);
                    } else {
                        $arSkuTmp[] = '';
                    }
                }
            }
            if (!empty($arCatalogProduct)) {
                $arSkuTmp["BALANCE"] = $arCatalogProduct["QUANTITY"];
                $arSkuTmp["WEIGHT"] = $arCatalogProduct["WEIGHT"];
                $arSkuTmp["BARCODE_MULTI"] = $arCatalogProduct["BARCODE_MULTI"];
            } else {
                $arSkuTmp["BALANCE"] = 0;
                $arSkuTmp["WEIGHT"] = 0;
                $arSkuTmp["BARCODE_MULTI"] = 'N';
            }
            $arSkuTmp["USER_ID"] = $userId;
            $arSkuTmp["ID"] = $arOffer["ID"];
            $arSkuTmp["TYPE"] = $arOffer["CATALOG_TYPE"];
            $arSkuTmp["NAME"] = CUtil::JSEscape($arOffer["NAME"]);
            $arSkuTmp["PRODUCT_NAME"] = CUtil::JSEscape(htmlspecialcharsbx($productName));
            $arSkuTmp["PRODUCT_ID"] = $productId;
            $arSkuTmp["LID"] = CUtil::JSEscape($lid);
            $arSkuTmp["CAN_BUY"] = $arOffer["CAN_BUY"];
            $arSkuTmp["ACTIVE"] = $active;
            $arSkuTmp["EXTERNAL_ID"] = $arOffer['EXTERNAL_ID'];
            $arSku[] = $arSkuTmp;
        }
        if ((!is_array($arIblockOfferProps) || empty($arIblockOfferProps)) && is_array($arSku) && !empty($arSku)) {
            $arIblockOfferProps[0] = array("CODE" => "TITLE", "NAME" => GetMessage("SKU_TITLE"));
            foreach ($arSku as $key => $val) {
                $arSku[$key][0] = $val["NAME"];
            }
        }
        $arResult["SKU_ELEMENTS"] = $arSku;
        $arResult["SKU_PROPERTIES"] = $arIblockOfferProps;
        $arResult["OFFERS_IBLOCK_ID"] = $arOffersIblock[$arProduct["IBLOCK_ID"]];
    }
    return $arResult;
}
Example #20
0
        $arMatrix[$keyOffer] = $arOneRow;
    }
    if (-1 == $intSelected) {
        $intSelected = 0;
    }
    $arResult['JS_OFFERS'] = $arMatrix;
    $arResult['OFFERS_SELECTED'] = $intSelected;
    if ($arMatrix[$intSelected]['SLIDER_COUNT'] > 0) {
        $arResult['MORE_PHOTO'] = $arMatrix[$intSelected]['SLIDER'];
        $arResult['MORE_PHOTO_COUNT'] = $arMatrix[$intSelected]['SLIDER_COUNT'];
    }
    $arResult['OFFERS_IBLOCK'] = $arSKU['IBLOCK_ID'];
}
if ($arResult['MODULES']['catalog'] && $arResult['CATALOG']) {
    if ($arResult['CATALOG_TYPE'] == CCatalogProduct::TYPE_PRODUCT || $arResult['CATALOG_TYPE'] == CCatalogProduct::TYPE_SET) {
        CIBlockPriceTools::setRatioMinPrice($arResult, false);
        $arResult['MIN_BASIS_PRICE'] = $arResult['MIN_PRICE'];
    }
    if (CBXFeatures::IsFeatureEnabled('CatCompleteSet') && $arResult['CATALOG_TYPE'] == CCatalogProduct::TYPE_PRODUCT) {
        $rsSets = CCatalogProductSet::getList(array(), array('@OWNER_ID' => $arResult['ID'], '=SET_ID' => 0, '=TYPE' => CCatalogProductSet::TYPE_GROUP), false, false, array('ID', 'OWNER_ID'));
        if ($arSet = $rsSets->Fetch()) {
            $arResult['OFFER_GROUP'] = true;
        }
    }
}
if (!empty($arResult['DISPLAY_PROPERTIES'])) {
    foreach ($arResult['DISPLAY_PROPERTIES'] as $propKey => $arDispProp) {
        if ('F' == $arDispProp['PROPERTY_TYPE']) {
            unset($arResult['DISPLAY_PROPERTIES'][$propKey]);
        }
    }
Example #21
0
		!empty($arResult["ELEMENTS"])
		&& (
			!empty($arParams["OFFERS_FIELD_CODE"])
			|| !empty($arParams["OFFERS_PROPERTY_CODE"])
		)
	)
	{
		$arOffers = CIBlockPriceTools::GetOffersArray(
			array(
				'IBLOCK_ID' => $arParams["IBLOCK_ID"],
				'HIDE_NOT_AVAILABLE' => $arParams['HIDE_NOT_AVAILABLE'],
			)
			,$arResult["ELEMENTS"]
			,array(
				$arParams["OFFERS_SORT_FIELD"] => $arParams["OFFERS_SORT_ORDER"],
				$arParams["OFFERS_SORT_FIELD2"] => $arParams["OFFERS_SORT_ORDER2"],
			)
			,$arParams["OFFERS_FIELD_CODE"]
			,$arParams["OFFERS_PROPERTY_CODE"]
			,$arParams["OFFERS_LIMIT"]
			,$arResult["PRICES"]
			,$arParams['PRICE_VAT_INCLUDE']
			,$arConvertParams
		);
		if(!empty($arOffers))
		{
			$arElementOffer = array();
			foreach($arResult["ELEMENTS"] as $i => $id)
			{
				$arResult["ITEMS"][$i]["OFFERS"] = array();
				$arElementOffer[$id] = &$arResult["ITEMS"][$i]["OFFERS"];
Example #22
0
 /**
  * get sku for product.
  *
  * @param integer $USER_ID				User.
  * @param string  $LID					Site.
  * @param integer $PRODUCT_ID			Product id.
  * @param string  $PRODUCT_NAME			Product name.
  * @param string CURRENCY				Currency.
  * @param array $arProduct				Iblock list.
  * @return array|false
  */
 function GetProductSku($USER_ID, $LID, $PRODUCT_ID, $PRODUCT_NAME = '', $CURRENCY = '', $arProduct = array())
 {
     $USER_ID = (int) $USER_ID;
     $PRODUCT_ID = (int) $PRODUCT_ID;
     if ($PRODUCT_ID <= 0) {
         return false;
     }
     $LID = trim($LID);
     if ($LID == '') {
         return false;
     }
     $PRODUCT_NAME = trim($PRODUCT_NAME);
     $arResult = array();
     $arOffers = array();
     static $arCacheGroups = array();
     if (!is_set($arCacheGroups[$USER_ID])) {
         $arCacheGroups[$USER_ID] = CUser::GetUserGroup($USER_ID);
     }
     $arGroups = $arCacheGroups[$USER_ID];
     if (empty($arProduct)) {
         $arProduct = CSaleProduct::GetProductListIblockInfo(array($PRODUCT_ID));
     }
     static $arOffersIblock = array();
     if (!is_set($arOffersIblock[$arProduct["IBLOCK_ID"]])) {
         $mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]);
         if (is_array($mxResult)) {
             $arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"];
         }
     }
     if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0) {
         static $arCacheOfferProperties = array();
         if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]])) {
             $dbOfferProperties = CIBlock::GetProperties($arOffersIblock[$arProduct["IBLOCK_ID"]], array(), array("!XML_ID" => "CML2_LINK"));
             while ($arOfferProperties = $dbOfferProperties->Fetch()) {
                 $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties;
             }
         }
         $arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]];
         $arIblockOfferProps = array();
         $arIblockOfferPropsFilter = array();
         if (is_array($arOfferProperties)) {
             foreach ($arOfferProperties as $val) {
                 $arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
                 $arIblockOfferPropsFilter[] = $val["CODE"];
             }
         }
         $arOffers = CIBlockPriceTools::GetOffersArray($arProduct["IBLOCK_ID"], $PRODUCT_ID, array("ID" => "DESC"), array("NAME"), $arIblockOfferPropsFilter, 0, array(), 1, array(), $USER_ID, $LID);
         $arSku = array();
         $minItemPrice = 0;
         $minItemPriceFormat = "";
         $arSkuId = array();
         $arImgSku = array();
         foreach ($arOffers as $arOffer) {
             $arSkuId[] = $arOffer['ID'];
         }
         if (!empty($arSkuId)) {
             $res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL"));
             while ($arOfferImg = $res->GetNext()) {
                 $arImgSku[$arOfferImg["ID"]] = $arOfferImg;
             }
         }
         foreach ($arOffers as $arOffer) {
             $arPrice = CCatalogProduct::GetOptimalPrice($arOffer['ID'], 1, $arGroups, "N", array(), $LID);
             if (empty($arPrice)) {
                 break;
             } elseif (strlen($CURRENCY) > 0) {
                 $arPrice["PRICE"]["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
                 if ($arPrice["DISCOUNT_PRICE"] > 0) {
                     $arPrice["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
                 }
                 $arPrice["PRICE"]["CURRENCY"] = $CURRENCY;
             }
             $arSkuTmp = array();
             $arOffer["CAN_BUY"] = "N";
             $arCatalogProduct = CCatalogProduct::GetByID($arOffer['ID']);
             if (!empty($arCatalogProduct)) {
                 if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
                     $arOffer["CAN_BUY"] = "N";
                 } else {
                     $arOffer["CAN_BUY"] = "Y";
                 }
             }
             $arSkuTmp["ImageUrl"] = '';
             if ($arOffer["CAN_BUY"] == "Y") {
                 $productImg = "";
                 if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']])) {
                     if ('' == $PRODUCT_NAME) {
                         $PRODUCT_NAME = $arImgSku[$arOffer['ID']]["~NAME"];
                     }
                     if ($arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"] != "") {
                         $productImg = $arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"];
                     } elseif ($arImgSku[$arOffer['ID']]["DETAIL_PICTURE"] != "") {
                         $productImg = $arImgSku[$arOffer['ID']]["DETAIL_PICTURE"];
                     }
                     if ($productImg == "") {
                         if ($arProduct["PREVIEW_PICTURE"] != "") {
                             $productImg = $arProduct["PREVIEW_PICTURE"];
                         } elseif ($arProduct["DETAIL_PICTURE"] != "") {
                             $productImg = $arProduct["DETAIL_PICTURE"];
                         }
                     }
                     if ($productImg != "") {
                         $arFile = CFile::GetFileArray($productImg);
                         $productImg = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                         $arSkuTmp["ImageUrl"] = $productImg["src"];
                     }
                 }
             }
             if ($minItemPrice === 0 || $arPrice["DISCOUNT_PRICE"] < $minItemPrice) {
                 $minItemPrice = $arPrice["DISCOUNT_PRICE"];
                 $minItemPriceFormat = SaleFormatCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"]);
             }
             foreach ($arIblockOfferProps as $arCode) {
                 if (array_key_exists($arCode["CODE"], $arOffer["PROPERTIES"])) {
                     if (is_array($arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"])) {
                         $arSkuTmp[] = implode("/", $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"]);
                     } else {
                         $arSkuTmp[] = $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"];
                     }
                 }
             }
             if (!empty($arCatalogProduct)) {
                 $arSkuTmp["BALANCE"] = $arCatalogProduct["QUANTITY"];
                 $arSkuTmp["WEIGHT"] = $arCatalogProduct["WEIGHT"];
                 $arSkuTmp["BARCODE_MULTI"] = $arCatalogProduct["BARCODE_MULTI"];
             } else {
                 $arSkuTmp["BALANCE"] = 0;
                 $arSkuTmp["WEIGHT"] = 0;
                 $arSkuTmp["BARCODE_MULTI"] = 'N';
             }
             $urlEdit = CIBlock::GetAdminElementEditLink($arOffer["IBLOCK_ID"], $arOffer['ID'], array('find_section_section' => 0, 'WF' => 'Y'));
             $discountPercent = 0;
             $arSkuTmp["USER_ID"] = $USER_ID;
             $arSkuTmp["ID"] = $arOffer["ID"];
             $arSkuTmp["NAME"] = CUtil::JSEscape($arOffer["NAME"]);
             $arSkuTmp["PRODUCT_NAME"] = CUtil::JSEscape($PRODUCT_NAME);
             $arSkuTmp["PRODUCT_ID"] = $PRODUCT_ID;
             $arSkuTmp["LID"] = CUtil::JSEscape($LID);
             $arSkuTmp["MIN_PRICE"] = $minItemPriceFormat;
             $arSkuTmp["URL_EDIT"] = $urlEdit;
             $arSkuTmp["DISCOUNT_PRICE"] = '';
             $arSkuTmp["DISCOUNT_PRICE_FORMATED"] = '';
             $arSkuTmp["PRICE"] = $arPrice["PRICE"]["PRICE"];
             $arSkuTmp["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], false);
             $arPriceType = GetCatalogGroup($arPrice["PRICE"]["CATALOG_GROUP_ID"]);
             $arSkuTmp["PRICE_TYPE"] = $arPriceType["NAME_LANG"];
             $arSkuTmp["VAT_RATE"] = $arPrice["PRICE"]["VAT_RATE"];
             if (count($arPrice["DISCOUNT"]) > 0) {
                 $discountPercent = IntVal($arPrice["DISCOUNT"]["VALUE"]);
                 $arSkuTmp["DISCOUNT_PRICE"] = $arPrice["DISCOUNT_PRICE"];
                 $arSkuTmp["DISCOUNT_PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], false);
             }
             $arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]);
             $arSkuTmp["VALUTA_FORMAT"] = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
             $arSkuTmp["DISCOUNT_PERCENT"] = $discountPercent;
             $arSkuTmp["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
             $arSkuTmp["CAN_BUY"] = $arOffer["CAN_BUY"];
             $arSku[] = $arSkuTmp;
         }
         if ((!is_array($arIblockOfferProps) || empty($arIblockOfferProps)) && is_array($arSku) && !empty($arSku)) {
             $arIblockOfferProps[0] = array("CODE" => "TITLE", "NAME" => GetMessage("SKU_TITLE"));
             foreach ($arSku as $key => $val) {
                 $arSku[$key][0] = $val["NAME"];
             }
         }
         $arResult["SKU_ELEMENTS"] = $arSku;
         $arResult["SKU_PROPERTIES"] = $arIblockOfferProps;
         $arResult["OFFERS_IBLOCK_ID"] = $arOffersIblock[$arProduct["IBLOCK_ID"]];
     }
     //if OFFERS_IBLOCK_ID > 0
     return $arResult;
 }
Example #23
0
         			}*/
         if (-1 == $intSelected) {
             $intSelected = 0;
         }
         /*if (!$arMatrix[$intSelected]['OWNER_PICT'])
         		{
         			$arItem['PREVIEW_PICTURE'] = $arMatrix[$intSelected]['PREVIEW_PICTURE'];
         			$arItem['PREVIEW_PICTURE_SECOND'] = $arMatrix[$intSelected]['PREVIEW_PICTURE_SECOND'];
         		}*/
         $arItem['JS_OFFERS'] = $arMatrix;
         //$arItem['OFFERS_SELECTED'] = $intSelected;
         $arItem['OFFERS_PROPS_DISPLAY'] = $boolSKUDisplayProperties;
         $arItem['MIN_PRICE'] = CIShop::getMinPriceFromOffersExt($arItem['OFFERS'], $boolConvert ? $arResult['CONVERT_CURRENCY']['CURRENCY_ID'] : $strBaseCurrency);
     }
     if ($arItem['CATALOG'] && CCatalogProduct::TYPE_PRODUCT == $arItem['CATALOG_TYPE']) {
         CIBlockPriceTools::setRatioMinPrice($arItem, true);
     }
     if (!empty($arItem['DISPLAY_PROPERTIES'])) {
         foreach ($arItem['DISPLAY_PROPERTIES'] as $propKey => $arDispProp) {
             if ('F' == $arDispProp['PROPERTY_TYPE']) {
                 unset($arItem['DISPLAY_PROPERTIES'][$propKey]);
             }
         }
     }
     $arItem['LAST_ELEMENT'] = 'N';
     $arNewItemsList[$key] = $arItem;
 }
 $arNewItemsList[$key]['LAST_ELEMENT'] = 'Y';
 $arResult['ITEMS'] = $arNewItemsList;
 $arResult['SKU_PROPS'] = $skuPropList;
 $arResult['DEFAULT_PICTURE'] = $arEmptyPreview;
Example #24
0
 public static function GetSetItems($productID, $intType, $arProducInfo = array())
 {
     $arProductId = array();
     static $proxyCatalogProductSet = array();
     static $proxyCatalogSkuData = array();
     static $proxyCatalogProduct = array();
     static $proxyIblockProperty = array();
     static $proxyProductProperty = array();
     $proxyCatalogProductSetKey = $productID . "|" . $intType;
     if (!empty($proxyCatalogProductSet[$proxyCatalogProductSetKey]) && is_array($proxyCatalogProductSet[$proxyCatalogProductSetKey])) {
         $arSets = $proxyCatalogProductSet[$proxyCatalogProductSetKey];
     } else {
         $arSets = CCatalogProductSet::getAllSetsByProduct($productID, $intType);
         if (!empty($arSets) && is_array($arSets)) {
             $proxyCatalogProductSet[$proxyCatalogProductSetKey] = $arSets;
         }
     }
     if (is_array($arSets)) {
         foreach ($arSets as $k => $arSet) {
             foreach ($arSet["ITEMS"] as $k1 => $item) {
                 $arItem = self::GetProductData(array("PRODUCT_ID" => $item["ITEM_ID"], "QUANTITY" => $item["QUANTITY"], "CHECK_QUANTITY" => "N", "CHECK_PRICE" => "N"));
                 if (array_key_exists('QUANTITY_TRACE', $arItem)) {
                     unset($arItem['QUANTITY_TRACE']);
                 }
                 $arItem["PRODUCT_ID"] = $item["ITEM_ID"];
                 $arItem["MODULE"] = "catalog";
                 $arItem["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                 if ($intType == CCatalogProductSet::TYPE_SET) {
                     $arItem['SET_DISCOUNT_PERCENT'] = $item['DISCOUNT_PERCENT'] == '' ? false : (double) $item['DISCOUNT_PERCENT'];
                 }
                 $arProductId[] = $item["ITEM_ID"];
                 $arItem["PROPS"] = array();
                 if (!empty($proxyCatalogSkuData[$item["ITEM_ID"]]) && is_array($proxyCatalogSkuData[$item["ITEM_ID"]])) {
                     $arParentSku = $proxyCatalogSkuData[$item["ITEM_ID"]];
                 } else {
                     if ($arParentSku = CCatalogSku::GetProductInfo($item["ITEM_ID"])) {
                         $proxyCatalogSkuData[$item["ITEM_ID"]] = $arParentSku;
                     }
                 }
                 if (!empty($arParentSku)) {
                     $arPropsSku = array();
                     if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT', $item["ITEM_ID"]))) {
                         $dbProduct = CIBlockElement::GetList(array(), array("ID" => $item["ITEM_ID"]), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'IBLOCK_SECTION_ID'));
                         if ($arProduct = $dbProduct->Fetch()) {
                             static::setHitCache('IBLOCK_ELEMENT', $item["ITEM_ID"], $arProduct);
                         }
                     }
                     if (!($arPropsSku = static::getHitCache('IBLOCK_PROPERTY', $arProduct["IBLOCK_ID"]))) {
                         $dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
                         while ($arOfferProperties = $dbOfferProperties->Fetch()) {
                             $arPropsSku[] = $arOfferProperties["CODE"];
                         }
                         static::setHitCache('IBLOCK_PROPERTY', $arProduct["IBLOCK_ID"], $arPropsSku);
                     }
                     $proxyProductPropertyKey = $item["ITEM_ID"] . "_" . $arParentSku["IBLOCK_ID"] . "_" . md5(join('|', $arPropsSku));
                     if (!($product_properties = static::getHitCache('PRODUCT_PROPERTY', $proxyProductPropertyKey))) {
                         $product_properties = CIBlockPriceTools::GetOfferProperties($item["ITEM_ID"], $arParentSku["IBLOCK_ID"], $arPropsSku);
                         static::setHitCache('PRODUCT_PROPERTY', $proxyProductPropertyKey, $product_properties);
                     }
                     foreach ($product_properties as $propData) {
                         $arItem["PROPS"][] = array("NAME" => $propData["NAME"], "CODE" => $propData["CODE"], "VALUE" => $propData["VALUE"], "SORT" => $propData["SORT"]);
                     }
                 }
                 $arSets[$k]["ITEMS"][$k1] = array_merge($item, $arItem);
             }
         }
         if (!($productList = static::getHitCache('IBLOCK_ELEMENT_LIST', $productID))) {
             $rsProducts = CIBlockElement::GetList(array(), array('ID' => $arProductId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "IBLOCK_TYPE_ID", "XML_ID"));
             while ($arProduct = $rsProducts->GetNext()) {
                 $productList[] = $arProduct;
             }
             if (!empty($productList) && is_array($productList)) {
                 static::setHitCache('IBLOCK_ELEMENT_LIST', $productID, $productList);
             }
         }
         if (!empty($productList) && is_array($productList)) {
             foreach ($productList as $arProduct) {
                 foreach ($arSets as $k => $arSet) {
                     foreach ($arSet["ITEMS"] as $k1 => $item) {
                         if ($item["ITEM_ID"] == $arProduct["ID"]) {
                             $arProps = array();
                             $strIBlockXmlID = strval(CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID'));
                             if ($strIBlockXmlID != "") {
                                 $arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $strIBlockXmlID);
                             }
                             $arProps[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arProduct["XML_ID"]);
                             $arSets["{$k}"]["ITEMS"][$k1]["IBLOCK_ID"] = $arProduct["IBLOCK_ID"];
                             $arSets["{$k}"]["ITEMS"][$k1]["IBLOCK_SECTION_ID"] = $arProduct["IBLOCK_SECTION_ID"];
                             $arSets["{$k}"]["ITEMS"][$k1]["PREVIEW_PICTURE"] = $arProduct["PREVIEW_PICTURE"];
                             $arSets["{$k}"]["ITEMS"][$k1]["DETAIL_PICTURE"] = $arProduct["DETAIL_PICTURE"];
                             $arSets["{$k}"]["ITEMS"][$k1]["PROPS"] = array_merge($arSets["{$k}"]["ITEMS"][$k1]["PROPS"], $arProps);
                         }
                     }
                 }
             }
         }
     }
     foreach (GetModuleEvents("sale", "OnGetSetItems", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$arSets));
     }
     return $arSets;
 }
Example #25
0
            if ($arProp['ID'] == $arSKU['SKU_PROPERTY_ID']) {
                continue;
            }
            $arProp['USER_TYPE'] = (string) $arProp['USER_TYPE'];
            $strPropName = '[' . $arProp['ID'] . ']' . ('' != $arProp['CODE'] ? '[' . $arProp['CODE'] . ']' : '') . ' ' . $arProp['NAME'];
            if ('' == $arProp['CODE']) {
                $arProp['CODE'] = $arProp['ID'];
            }
            $arAllOfferPropList[$arProp['CODE']] = $strPropName;
            if ('F' == $arProp['PROPERTY_TYPE']) {
                $arFileOfferPropList[$arProp['CODE']] = $strPropName;
            }
            if ('N' != $arProp['MULTIPLE']) {
                continue;
            }
            if ('L' == $arProp['PROPERTY_TYPE'] || 'E' == $arProp['PROPERTY_TYPE'] || 'S' == $arProp['PROPERTY_TYPE'] && 'directory' == $arProp['USER_TYPE'] && CIBlockPriceTools::checkPropDirectory($arProp)) {
                $arTreeOfferPropList[$arProp['CODE']] = $strPropName;
            }
        }
        $arTemplateParameters['OFFER_ADD_PICT_PROP'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_OFFER_ADD_PICT_PROP'), 'TYPE' => 'LIST', 'MULTIPLE' => 'N', 'ADDITIONAL_VALUES' => 'N', 'REFRESH' => 'N', 'DEFAULT' => '-', 'VALUES' => $arFileOfferPropList);
        $arTemplateParameters['OFFER_TREE_PROPS'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_OFFER_TREE_PROPS'), 'TYPE' => 'LIST', 'MULTIPLE' => 'Y', 'ADDITIONAL_VALUES' => 'N', 'REFRESH' => 'N', 'DEFAULT' => '-', 'VALUES' => $arTreeOfferPropList);
    }
}
if ($boolCatalog) {
    $arTemplateParameters['SHOW_DISCOUNT_PERCENT'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_SHOW_DISCOUNT_PERCENT'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N');
    $arTemplateParameters['SHOW_OLD_PRICE'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_SHOW_OLD_PRICE'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N');
}
if (isset($arCurrentValues['VIEW_MODE']) && ('SLIDER' == $arCurrentValues['VIEW_MODE'] || 'BANNER' == $arCurrentValues['VIEW_MODE'])) {
    $arTemplateParameters['ROTATE_TIMER'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_ROTATE_TIMER'), 'TYPE' => 'STRING', 'DEFAULT' => '30');
    $arTemplateParameters['SHOW_PAGINATION'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_SHOW_PAGINATION'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'Y');
}
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$curSkuView = COption::GetOptionString("eshop", "catalogDetailSku", "select", SITE_ID);
if (is_array($arResult["OFFERS"]) && !empty($arResult["OFFERS"])) {
    $pricesCount = count($arResult["CAT_PRICES"]);
    $arOffersIblock = CIBlockPriceTools::GetOffersIBlock($arResult["IBLOCK_ID"]);
    $OFFERS_IBLOCK_ID = is_array($arOffersIblock) ? $arOffersIblock["OFFERS_IBLOCK_ID"] : 0;
    $dbOfferProperties = CIBlock::GetProperties($OFFERS_IBLOCK_ID, array(), array("!XML_ID" => "CML2_LINK"));
    $arIblockOfferProps = array();
    $offerPropsExists = false;
    while ($arOfferProperties = $dbOfferProperties->Fetch()) {
        if (!in_array($arOfferProperties["CODE"], $arParams["OFFERS_PROPERTY_CODE"])) {
            continue;
        }
        $arIblockOfferProps[] = array("CODE" => $arOfferProperties["CODE"], "NAME" => $arOfferProperties["NAME"]);
        $offerPropsExists = true;
    }
    foreach ($arIblockOfferProps as $key => $arCode) {
        $emptyProp = true;
        foreach ($arResult["OFFERS"] as $key2 => $arOffer) {
            if (array_key_exists($arCode["CODE"], $arOffer["PROPERTIES"]) && !empty($arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"])) {
                $emptyProp = false;
            }
        }
        if ($emptyProp) {
            unset($arIblockOfferProps[$key]);
        }
    }
Example #27
0
/** @var array $arResult */
/** @var string $componentPath */
/** @var string $componentName */
/** @var string $componentTemplate */
/** @global CDatabase $DB */
/** @global CUser $USER */
/** @global CMain $APPLICATION */
if (!Loader::includeModule('iblock')) {
    ShowError(GetMessage("CC_BCF_MODULE_NOT_INSTALLED"));
    return;
}
$FILTER_NAME = (string) $arParams["FILTER_NAME"];
if ($this->StartResultCache(false, $arParams["CACHE_GROUPS"] ? $USER->GetGroups() : false)) {
    $arResult["FACET_FILTER"] = false;
    $arResult["COMBO"] = array();
    $arResult["PRICES"] = CIBlockPriceTools::GetCatalogPrices($arParams["IBLOCK_ID"], $arParams["PRICE_CODE"]);
    $arResult["ITEMS"] = $this->getResultItems();
    $arResult["CURRENCIES"] = array();
    $propertyEmptyValuesCombination = array();
    foreach ($arResult["ITEMS"] as $PID => $arItem) {
        $propertyEmptyValuesCombination[$arItem["ID"]] = array();
    }
    if (!empty($arResult["ITEMS"])) {
        if ($this->facet->isValid()) {
            $this->facet->setPrices($arResult["PRICES"]);
            $this->facet->setSectionId($this->SECTION_ID);
            $arResult["FACET_FILTER"] = array("ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y");
            if ($this->arParams['HIDE_NOT_AVAILABLE'] == 'Y') {
                $arResult["FACET_FILTER"]['CATALOG_AVAILABLE'] = 'Y';
            }
            $res = $this->facet->query($arResult["FACET_FILTER"]);
Example #28
0
         }
         if ($price['MIN_PRICE'] == "Y") {
             $item['PRICE_CURRENCY'] = $price['CURRENCY'];
             $item['PRICE_DISCOUNT_VALUE'] = $price['DISCOUNT_VALUE'];
             $item['PRICE_PRINT_DISCOUNT_VALUE'] = $price['PRINT_DISCOUNT_VALUE'];
             $item['PRICE_VALUE'] = $price['VALUE'];
             $item['PRICE_PRINT_VALUE'] = $price['PRINT_VALUE'];
             $item['PRICE_DISCOUNT_DIFFERENCE_VALUE'] = $price['DISCOUNT_DIFF'];
             $item['PRICE_DISCOUNT_DIFFERENCE'] = $price['PRINT_DISCOUNT_DIFF'];
             $item['PRICE_DISCOUNT_PERCENT'] = $price['DISCOUNT_DIFF_PERCENT'];
             break;
         }
     }
     unset($price, $priceList);
     //TODO: end
     $item['CAN_BUY'] = CIBlockPriceTools::CanBuy($item['IBLOCK_ID'], $arResult['PRICES'], $item);
     if (!empty($productLink[$item['ID']])) {
         foreach ($productLink[$item['ID']] as &$index) {
             $currentSet['ITEMS'][$index]['ITEM_DATA'] = $item;
         }
         unset($index);
     } elseif ($item['ID'] == $arResult['ELEMENT_ID']) {
         $currentSet['ITEM_DATA'] = $item;
     }
 }
 unset($select, $item, $itemsIterator);
 if (!$found || empty($currentSet['ITEM_DATA'])) {
     $this->AbortResultCache();
     return;
 }
 $defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
         	else
         	{
         		if (!empty($arItem["PRICES"]))
         		{
         			foreach ($arItem["PRICES"] as &$arOnePrices)
         			{
         				if (isset($arOnePrices['ORIG_CURRENCY']))
         					$arCurrencyList[] = $arOnePrices['ORIG_CURRENCY'];
         			}
         			if (isset($arOnePrices))
         				unset($arOnePrices);
         		}
         	}
         }
         */
         $arItem["CAN_BUY"] = CIBlockPriceTools::CanBuy($arParams["LINK_IBLOCK_ID"], $arResult["PRICES"], $arElement);
     }
 }
 if ('Y' == $arParams['CONVERT_CURRENCY']) {
     if (!empty($arCurrencyList)) {
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $arCurrencyList[] = $arConvertParams['CURRENCY_ID'];
             $arCurrencyList = array_unique($arCurrencyList);
             $CACHE_MANAGER->StartTagCache($this->__component->GetCachePath());
             foreach ($arCurrencyList as &$strOneCurrency) {
                 $CACHE_MANAGER->RegisterTag("currency_id_" . $strOneCurrency);
             }
             if (isset($strOneCurrency)) {
                 unset($strOneCurrency);
             }
             $CACHE_MANAGER->EndTagCache();
Example #30
0
	if(
		!empty($arResult["ELEMENTS"])
		&& (
			!empty($arParams["OFFERS_FIELD_CODE"])
			|| !empty($arParams["OFFERS_PROPERTY_CODE"])
		)
	)
	{
		$arOffers = CIBlockPriceTools::GetOffersArray(
			$arParams["IBLOCK_ID"]
			,$arResult["ELEMENTS"]
			,array(
				$arParams["OFFERS_SORT_FIELD"] => $arParams["OFFERS_SORT_ORDER"],
				"ID" => "DESC",
			)
			,$arParams["OFFERS_FIELD_CODE"]
			,$arParams["OFFERS_PROPERTY_CODE"]
			,$arParams["OFFERS_LIMIT"]
			,$arResult["PRICES"]
			,$arParams['PRICE_VAT_INCLUDE']
			,$arConvertParams
		);
		if(!empty($arOffers))
		{
			$arElementOffer = array();
			foreach($arResult["ELEMENTS"] as $i => $id)
			{
				$arResult["ITEMS"][$i]["OFFERS"] = array();
				$arElementOffer[$id] = &$arResult["ITEMS"][$i]["OFFERS"];
			}