当前位置: 首页>>代码示例>>PHP>>正文


PHP CIBlockPriceTools::GetOffersArray方法代码示例

本文整理汇总了PHP中CIBlockPriceTools::GetOffersArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockPriceTools::GetOffersArray方法的具体用法?PHP CIBlockPriceTools::GetOffersArray怎么用?PHP CIBlockPriceTools::GetOffersArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIBlockPriceTools的用法示例。


在下文中一共展示了CIBlockPriceTools::GetOffersArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: productView

 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;
     }
 }
开发者ID:akniyev,项目名称:arteva.ru,代码行数:54,代码来源:cConveadTracker.php

示例2: array

 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']);
                 }
开发者ID:rasuldev,项目名称:torino,代码行数:31,代码来源:component.php

示例3: array

		!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"];
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:31,代码来源:component.php

示例4: GetProductSku

/**
 * @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"];
                    }
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:101,代码来源:cat_store_product_search.php

示例5: array

	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"];
			}
开发者ID:ASDAFF,项目名称:bitrixlazycomp,代码行数:30,代码来源:component.php

示例6: GetProductSku

 /**
  * 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"];
                     }
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:product.php

示例7: array

 $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"];*/
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php

示例8: setItemsOffers

 /**
  * 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);
 }
开发者ID:akniyev,项目名称:arteva.ru,代码行数:77,代码来源:class.php

示例9: setItemsOffers

 /**
  * 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);
 }
开发者ID:Satariall,项目名称:izurit,代码行数:68,代码来源:class.php

示例10: getFinalPriceInCurrency

function getFinalPriceInCurrency($item_id, $sale_currency = 'UAH')
{
    global $USER;
    // Do item have offers?
    if (CCatalogSku::IsExistOffers($item_id)) {
        // Find price in offers
        $res = CIBlockElement::GetByID($item_id);
        if ($ar_res = $res->GetNext()) {
            if (isset($ar_res['IBLOCK_ID']) && $ar_res['IBLOCK_ID']) {
                // Find all offers
                $offers = CIBlockPriceTools::GetOffersArray(array('IBLOCK_ID' => $ar_res['IBLOCK_ID'], 'HIDE_NOT_AVAILABLE' => 'Y', 'CHECK_PERMISSIONS' => 'Y'), array($item_id), null, null, null, null, null, null, array('CURRENCY_ID' => $sale_currency), $USER->getId(), null);
                foreach ($offers as $offer) {
                    $price = CCatalogProduct::GetOptimalPrice($offer['ID'], 1, $USER->GetUserGroupArray(), 'N');
                    if (isset($price['PRICE'])) {
                        if ($price['PRICE']['CURRENCY'] != $sale_currency) {
                            $price['PRICE']['PRICE'] = CCurrencyRates::ConvertCurrency($price['PRICE']['PRICE'], $price['PRICE']['CURRENCY'], $sale_currency);
                            $price['PRICE']['CURRENCY'] = $sale_currency;
                        }
                        $price['PRICE']['PRICE_WITH_DISCOUNT'] = $price['PRICE']['PRICE'];
                        $currency_code = $price['PRICE']['CURRENCY'];
                        // Find discounts and calculate price with discounts
                        $arDiscounts = CCatalogDiscount::GetDiscountByProduct($item_id, $USER->GetUserGroupArray(), "N");
                        if (is_array($arDiscounts) && sizeof($arDiscounts) > 0) {
                            $price['PRICE']['PRICE_WITH_DISCOUNT'] = CCatalogProduct::CountPriceWithDiscount($price['PRICE']['PRICE_WITH_DISCOUNT'], $sale_currency, $arDiscounts);
                        }
                        // Stop cycle, use found value
                        break;
                    }
                }
            }
        }
    } else {
        // Simple product, not trade offers
        $price = CCatalogProduct::GetOptimalPrice($item_id, 1, $USER->GetUserGroupArray(), 'N');
        // Got price?
        if (!$price || !isset($price['PRICE'])) {
            return false;
        }
        if ($price['PRICE']['CURRENCY'] != $sale_currency) {
            $price['PRICE']['PRICE'] = CCurrencyRates::ConvertCurrency($price['PRICE']['PRICE'], $price['PRICE']['CURRENCY'], $sale_currency);
            $price['DISCOUNT_PRICE'] = CCurrencyRates::ConvertCurrency($price['DISCOUNT_PRICE'], $price['PRICE']['CURRENCY'], $sale_currency);
            $price['PRICE']['CURRENCY'] = $sale_currency;
        }
        // Change currency code if found
        if (isset($price['CURRENCY'])) {
            $currency_code = $price['CURRENCY'];
        }
        if (isset($price['PRICE']['CURRENCY'])) {
            $currency_code = $price['PRICE']['CURRENCY'];
        }
        // Get final price
        $price['PRICE']['PRICE_WITH_DISCOUNT'] = $price['DISCOUNT_PRICE'];
        // Find discounts and calculate price with discounts
        $arDiscounts = CCatalogDiscount::GetDiscountByProduct($item_id, $USER->GetUserGroupArray(), "N", 2);
        if (is_array($arDiscounts) && sizeof($arDiscounts) > 0) {
            $price['PRICE']['PRICE_WITH_DISCOUNT'] = CCatalogProduct::CountPriceWithDiscount($price['PRICE']['PRICE_WITH_DISCOUNT'], $sale_currency, $arDiscounts);
        }
    }
    // Convert to sale currency if needed
    if ($currency_code != $sale_currency) {
        $price['PRICE']['PRICE_WITH_DISCOUNT'] = CCurrencyRates::ConvertCurrency($price['PRICE']['PRICE_WITH_DISCOUNT'], $sale_currency, $sale_currency);
    }
    return $price;
}
开发者ID:VitaliiSestrenskyi,项目名称:sest,代码行数:64,代码来源:complects.php


注:本文中的CIBlockPriceTools::GetOffersArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。