本文整理汇总了PHP中CPrice::GetList方法的典型用法代码示例。如果您正苦于以下问题:PHP CPrice::GetList方法的具体用法?PHP CPrice::GetList怎么用?PHP CPrice::GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPrice
的用法示例。
在下文中一共展示了CPrice::GetList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeComponent
function executeComponent()
{
$arFilter = array('IBLOCK_ID' => $this->arParams['IBLOCK_ID'], 'ACTIVE' => 'Y');
if (true || $this->StartResultCache()) {
$CIBlockElement = new CIBlockElement();
$CFile = new \CFile();
$aElts = array();
$eltsSelectFields = array_merge(array('ID', 'NAME', 'CODE', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'DETAIL_PAGE_URL'), $this->getIBlockProperties($this->arParams['IBLOCK_ID']));
$rsElts = $CIBlockElement->GetList(array('SORT' => 'asc', 'date_active_from' => 'DESC'), $arFilter, false, false, array('ID', 'NAME'));
if (intval($rsElts->SelectedRowsCount())) {
while ($arElt = $rsElts->Fetch()) {
$aElts[] = array('ID' => $arElt['ID'], 'NAME' => $arElt['NAME']);
}
$arElt = $CIBlockElement->GetList(array('SORT' => 'asc', 'ID' => 'DESC'), array_merge($arFilter, array('ID' => $aElts[0]['ID'])), false, false, $eltsSelectFields)->GetNext();
if ($arElt['DETAIL_PICTURE']) {
$arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['DETAIL_PICTURE']);
} elseif ($arElt['PREVIEW_PICTURE']) {
$arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['PREVIEW_PICTURE']);
}
$arPrice = CPrice::GetList(array(), array("PRODUCT_ID" => $arElt['ID']))->Fetch();
$arElt['PRICE'] = $arPrice['PRICE'];
$this->arResult['ITEMS'] = $aElts;
$this->arResult['ITEM'] = $arElt;
$this->IncludeComponentTemplate();
}
}
}
示例2: addPriceProducts
/**
* [addPriceProducts description]
* @param array $arParams
* @return bool
*/
protected function addPriceProducts($arParams){
if (!CModule::IncludeModule("iblock") && !CModule::IncludeModule("catalog") && !CModule::IncludeModule("sale")):
return false;
endif;
$PRICE_TYPE_ID = 1; // идентификатор типы базовой цены
$arFields = Array(
"PRODUCT_ID" => $arParams["PRODUCT_ID"],
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
"PRICE" => $arParams["OLD_PRICE"],
"CURRENCY" => "RUB",
"QUANTITY_FROM" => 1,
);
$res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $arParams["PRODUCT_ID"],
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID
)
);
if ($arr = $res->Fetch()):
if (!CPrice::Update($arr["ID"], $arFields)):
return false;
endif;
else:
if (!CPrice::Add($arFields)):
return false;
endif;
endif;
if (!$this->addCatalogProducts($arParams)):
return false;
endif;
return true;
}
示例3: setExtra
private function setExtra($productId, $priceTypeId, $extraId)
{
$list = CPrice::GetList(array(), array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $priceTypeId), false, false, array('ID', 'EXTRA_ID'));
$arFields = array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $priceTypeId, 'EXTRA_ID' => $extraId, 'CURRENCY' => 'USD');
if ($res = $list->Fetch()) {
if ($res['EXTRA_ID'] != $extraId) {
CPrice::Update($res['ID'], $arFields, true);
}
} else {
CPrice::Add($arFields, true);
}
unset($list);
unset($res);
unset($resultUp);
}
示例4: getFavoriteProducts
/**
* [getFavoriteProducts description]
* @param array $arFavorites
* @return array products
*/
function getFavoriteProducts($arFavorites)
{
global $USER;
foreach ($arFavorites as $key => $id) {
$arSelect = array();
$arFilter = array("IBLOCK_ID" => 17, "ACTIVE" => "Y", "ID" => $id);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
if ($ob = $res->GetNextElement()) {
$arItems = $ob->GetFields();
$arItems["PROPERTIES"] = $ob->GetProperties();
$dbPrice = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC", "SORT" => "ASC"), array("PRODUCT_ID" => $arItems["ID"]), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO"));
if ($arPrice = $dbPrice->Fetch()) {
$arDiscounts = CCatalogDiscount::GetDiscountByPrice($arPrice["ID"], $USER->GetUserGroupArray(), "N", SITE_ID);
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"], $arPrice["CURRENCY"], $arDiscounts);
$arPrice["DISCOUNT_VALUE"] = $discountPrice;
$arItems["PRICES"] = $arPrice;
}
}
if ($arItems) {
$arFav[] = $arItems;
}
}
return $arFav;
}
示例5: CatalogBasketCustomCallback
/**
* Функция обратного вызова для корзины
* аналогична функции CatalogBasketCallback за исключением использования одной определенной цены для конкретного города
*
* @param $productID
* @param $quantity
* @param $renewal
*/
function CatalogBasketCustomCallback($productID, $quantity = 0, $renewal = "N")
{
global $USER;
$productID = IntVal($productID);
$quantity = DoubleVal($quantity);
$renewal = (($renewal == "Y") ? "Y" : "N");
$arResult = array();
if ($arCatalogProduct = CCatalogProduct::GetByID($productID))
{
if ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && DoubleVal($arCatalogProduct["QUANTITY"])<=0)
return $arResult;
}
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE_DATE" => "Y",
"ACTIVE" => "Y",
"CHECK_PERMISSIONS" => "Y"
)
);
$arProduct = $dbIBlockElement->GetNext();
$arCatalog = CCatalog::GetByID($arProduct["IBLOCK_ID"]);
if ($arCatalog["SUBSCRIPTION"] == "Y")
{
$quantity = 1;
}
$rs = CPrice::GetList(
array(),
array("CATALOG_GROUP_NAME" => GetCityPrice(), "PRODUCT_ID" => $productID), false, false);
$ar = $rs -> Fetch();
$arPrice = array();
$arPrice[] = array(
"ID" => $ar["ID"],
"PRICE" => $ar["PRICE"],
"CURRENCY" => $ar["CURRENCY"],
"CATALOG_GROUP_ID" => $ar["CATALOG_GROUP_ID"]
);
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER -> GetUserGroupArray(), $renewal, $arPrice);
if (!$arPrice || count($arPrice) <= 0)
{
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $USER->GetUserGroupArray()))
{
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER->GetUserGroupArray(), $renewal);
}
}
if (!$arPrice || count($arPrice) <= 0)
{
return $arResult;
}
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
//SIGURD: logic change. see mantiss 5036.
// discount applied to a final price with VAT already included.
if ($arPrice['PRICE']['VAT_INCLUDED'] == 'N')
{
if(DoubleVal($arPrice['PRICE']['VAT_RATE']) > 0)
{
$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
$arPrice['PRICE']['VAT_INCLUDED'] = 'y';
}
}
if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0)
{
if ($arPrice["DISCOUNT"]["VALUE_TYPE"]=="F")
{
if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"])
$currentDiscount = $arPrice["DISCOUNT"]["VALUE"];
else
$currentDiscount = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT"]["VALUE"], $arPrice["DISCOUNT"]["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
else
$currentDiscount = $currentPrice * $arPrice["DISCOUNT"]["VALUE"] / 100.0;
$currentDiscount = roundEx($currentDiscount, SALE_VALUE_PRECISION);
if (DoubleVal($arPrice["DISCOUNT"]["MAX_DISCOUNT"]) > 0)
{
//.........这里部分代码省略.........
示例6: ReCalculate
function ReCalculate($TYPE, $ID, $VAL)
{
$ID = intval($ID);
if (0 < $ID)
{
if ('EXTRA' == $TYPE)
{
$db_res = CPrice::GetList(
array(),
array('EXTRA_ID' => $ID),
false,
false,
array('ID', 'PRODUCT_ID', 'EXTRA_ID', 'QUANTITY_FROM', 'QUANTITY_TO')
);
while ($res = $db_res->Fetch())
{
$arFields = array();
if ($arBasePrice = CPrice::GetBasePrice($res["PRODUCT_ID"], $res["QUANTITY_FROM"], $res["QUANTITY_TO"]))
{
$arFields["PRICE"] = RoundEx($arBasePrice["PRICE"] * (1 + 1 * $VAL / 100), 2);
$arFields["CURRENCY"] = $arBasePrice["CURRENCY"];
CPrice::Update($res["ID"], $arFields);
}
}
}
else
{
$db_res = CPrice::GetList(
array(),
array("PRODUCT_ID" => $ID),
false,
false,
array('ID', 'PRODUCT_ID', 'EXTRA_ID')
);
while ($res = $db_res->Fetch())
{
$res["EXTRA_ID"] = intval($res["EXTRA_ID"]);
if (0 < $res["EXTRA_ID"])
{
$res1 = CExtra::GetByID($res["EXTRA_ID"]);
$arFields = array(
"PRICE" => $VAL * (1 + 1 * $res1["PERCENTAGE"] / 100),
);
CPrice::Update($res["ID"], $arFields);
}
}
}
}
}
示例7: GetMessage
echo GetMessage("C2IT_PRICE");
?>
</td>
<td align="center"><?php
echo GetMessage("C2IT_CURRENCY");
?>
</td>
</tr>
</thead>
<tbody id="container3_<?php
echo $arCatalogGroup["ID"];
?>
">
<?php
$ind = -1;
$dbPriceList = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"), array("PRODUCT_ID" => $PRODUCT_ID, "CATALOG_GROUP_ID" => $arCatalogGroup["ID"]));
$arPrice = $dbPriceList->Fetch();
for ($i = 0, $intCount = count($arPriceBoundaries); $i < $intCount; $i++) {
$boolExistPrice = false;
$ind++;
$str_CAT_QUANTITY_FROM = $arPriceBoundaries[$i]["FROM"];
$str_CAT_QUANTITY_TO = $arPriceBoundaries[$i]["TO"];
if ($arPrice && intval($arPrice["QUANTITY_FROM"]) == $arPriceBoundaries[$i]["FROM"]) {
$str_CAT_ID = $arPrice["ID"];
$str_CAT_EXTRA = $arPrice["EXTRA_ID"];
$str_CAT_PRICE = $arPrice["PRICE"];
$str_CAT_CURRENCY = $arPrice["CURRENCY"];
$arPrice = $dbPriceList->Fetch();
} else {
$str_CAT_ID = 0;
$str_CAT_EXTRA = 0;
示例8: fGetFormatedProductData
{
$viewed['MODULE'] = 'catalog';
$arViewed[$viewedCount] = $viewed;
$arViewedIds[] = $viewed['PRODUCT_ID'];
$mapViewed[$viewed['PRODUCT_ID']] = $viewedCount;
$viewedCount++;
}
unset($viewedCount);
if (!empty($arViewedIds))
{
$baseGroup = CCatalogGroup::getBaseGroup();
$priceIterator = CPrice::GetList(
array(),
array("PRODUCT_ID" => $arViewedIds, 'CATALOG_GROUP_ID' => $baseGroup['ID']),
false,
false,
array("PRODUCT_ID", "PRICE", "CURRENCY")
);
while($productPrice = $priceIterator->fetch() )
{
if (isset($mapViewed[$productPrice['PRODUCT_ID']]))
{
$key = $mapViewed[$productPrice['PRODUCT_ID']];
$arViewed[$key]["PRICE"] = $productPrice["PRICE"];
$arViewed[$key]["CURRENCY"] = $productPrice["CURRENCY"];
}
}
}
$arResult["ITEMS"] = fGetFormatedProductData($userId, $LID, $arViewed, 1, $currency, $type, $crmMode);
}
示例9: exportElement
function exportElement($arElement, $SECTION_MAP, $PROPERTY_MAP)
{
if (strlen($arElement["XML_ID"]) > 0) {
$xml_id = $arElement["XML_ID"];
} else {
$xml_id = $arElement["ID"];
}
if ($this->PRODUCT_IBLOCK_ID > 0) {
$arPropOrder = array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc");
$rsLink = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE" => "Y", "CODE" => "CML2_LINK"));
$arLink = $rsLink->Fetch();
if (is_array($arLink) && !is_array($arLink["VALUE"]) && $arLink["VALUE"] > 0) {
$xml_id = $this->GetElementXML_ID($this->PRODUCT_IBLOCK_ID, $arLink["VALUE"]) . "#" . $xml_id;
}
}
fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_ID") . ">" . htmlspecialcharsbx($xml_id) . "</" . GetMessage("IBLOCK_XML2_ID") . ">\n");
if (!$this->only_price) {
$this->exportElementFields($arElement, $SECTION_MAP);
if ($this->next_step["catalog"] && !$this->bExtended) {
fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTES") . ">\n");
} else {
fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTIES_VALUES") . ">\n");
}
$this->exportElementProperties($arElement, $PROPERTY_MAP);
if ($this->next_step["catalog"] && !$this->bExtended) {
fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTES") . ">\n");
} else {
fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTIES_VALUES") . ">\n");
}
if ($this->bExtended) {
$elementTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($this->arIBlock["ID"], $arElement["ID"]);
$this->exportInheritedTemplates(4, $elementTemplates);
}
}
if ($this->next_step["catalog"]) {
$rsProduct = CCatalogProduct::GetList(array(), array("ID" => $arElement["ID"]));
$arProduct = $rsProduct->Fetch();
static $measure = null;
if (!isset($measure)) {
$measure = array();
$rsBaseUnit = CCatalogMeasure::GetList(array(), array());
while ($arIDUnit = $rsBaseUnit->Fetch()) {
$measure[$arIDUnit["ID"]] = $arIDUnit["CODE"];
}
}
$xmlMeasure = GetMessage("IBLOCK_XML2_PCS");
if ($arProduct["MEASURE"] > 0 && isset($measure[$arProduct["MEASURE"]])) {
$xmlMeasure = $measure[$arProduct["MEASURE"]];
}
$arPrices = array();
$rsPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $arElement["ID"]));
while ($arPrice = $rsPrices->Fetch()) {
if (!$arPrice["QUANTITY_FROM"] && !$arPrice["QUANTITY_TO"]) {
$arPrices[] = array(GetMessage("IBLOCK_XML2_PRICE_TYPE_ID") => $this->prices[$arPrice["CATALOG_GROUP_ID"]], GetMessage("IBLOCK_XML2_PRICE_FOR_ONE") => $arPrice["PRICE"], GetMessage("IBLOCK_XML2_CURRENCY") => $arPrice["CURRENCY"], GetMessage("IBLOCK_XML2_MEASURE") => $xmlMeasure);
}
}
if (count($arPrices) > 0) {
fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_PRICES") . ">\n");
foreach ($arPrices as $arPrice) {
fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_PRICE") . ">\n");
foreach ($arPrice as $key => $value) {
fwrite($this->fp, "\t\t\t\t\t\t<" . $key . ">" . htmlspecialcharsbx($value) . "</" . $key . ">\n");
}
fwrite($this->fp, "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_PRICE") . ">\n");
}
fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_PRICES") . ">\n");
$arCatalogProduct = CCatalogProduct::GetByID($arElement["ID"]);
if ($arCatalogProduct) {
fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_AMOUNT") . ">" . htmlspecialcharsbx($arCatalogProduct["QUANTITY"]) . "</" . GetMessage("IBLOCK_XML2_AMOUNT") . ">\n");
}
}
}
}
示例10:
"IBLOCK_ID" => "3",
"PROPERTY_CML2_LINK" => $arItem["ID"]
),
false,
array(
"nTopCount" => 1
),
array()
);
if ($arQuery = $dbQuery->Fetch())
{
$arPrice = CPrice::GetBasePrice($arQuery["ID"]);
$arItem["PRICE"] = $arPrice["PRICE"];
}
else
{
$arPrice = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $arItem["ID"]
),
false,
array(
"nTopCount" => 1
),
array()
)->Fetch();
$arItem["PRICE"] = $arPrice["PRICE"];
}
}
示例11: array
),
false,
false,
array("ID","NAME","*")
);
$arrOffer = array();
$arrProp = array();
while ($arOffer = $rsOffers->GetNextElement()){
$arrOffer = $arOffer->GetFields();
$arrProp = $arOffer->GetProperties();
$arrOffer['PROPERTIES']['CML2_ATTRIBUTES'] = $arrProp['CML2_ATTRIBUTES'];
$price = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $arrOffer['ID'],
"CATALOG_GROUP_ID" => $arResult['PRICES_ALLOW'][0]
)
);
if ($ar_res = $price->Fetch())
{
$arrOffer['PRICE'] = $ar_res;
}
array_push($offer,$arrOffer);
}
$arResult['ITEMS'][$key]['OFFERS_LIST'] = $offer;
/*
$res = CCatalogSKU::getOffersList(
$arItem['ID'], // массив ID товаров
$iblockID = $arResult['IBLOCK_ID'], // указываете ID инфоблока только в том случае, когда ВЕСЬ массив товаров из одного инфоблока и он известен
$skuFilter = array(), // дополнительный фильтр предложений. по умолчанию пуст.
示例12: ReCountFromBase
public static function ReCountFromBase(&$arFields, &$boolBase)
{
$arBaseGroup = CCatalogGroup::GetBaseGroup();
if (!empty($arBaseGroup))
{
if ($arFields['CATALOG_GROUP_ID'] == $arBaseGroup['ID'])
{
$boolBase = true;
}
else
{
if (!empty($arFields['EXTRA_ID']) && intval($arFields['EXTRA_ID']) > 0)
{
$arExtra = CExtra::GetByID($arFields['EXTRA_ID']);
if (!empty($arExtra))
{
$arFilter = array('PRODUCT_ID' => $arFields['PRODUCT_ID'],'CATALOG_GROUP_ID' => $arBaseGroup['ID']);
if (isset($arFields['QUANTITY_FROM']))
$arFilter['QUANTITY_FROM'] = $arFields['QUANTITY_FROM'];
if (isset($arFields['QUANTITY_TO']))
$arFilter['QUANTITY_TO'] = $arFields['QUANTITY_TO'];
$rsBasePrices = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"),
$arFilter,false,array('nTopCount' => 1),array('PRICE','CURRENCY'));
if ($arBasePrice = $rsBasePrices->Fetch())
{
$arFields['CURRENCY'] = $arBasePrice['CURRENCY'];
$arFields['PRICE'] = RoundEx($arBasePrice["PRICE"] * (1 + DoubleVal($arExtra["PERCENTAGE"])/100), CATALOG_VALUE_PRECISION);
}
}
else
{
$arFields['EXTRA_ID'] = 0;
}
}
}
}
}
示例13: DoIBlockAfterSave
function DoIBlockAfterSave($arg1, $arg2 = false)
{
$ELEMENT_ID = false;
$IBLOCK_ID = false;
$OFFERS_IBLOCK_ID = false;
$OFFERS_PROPERTY_ID = false;
if (CModule::IncludeModule('currency')) {
$strDefaultCurrency = CCurrency::GetBaseCurrency();
}
//Check for catalog event
if (is_array($arg2) && $arg2["PRODUCT_ID"] > 0) {
//Get iblock element
$rsPriceElement = CIBlockElement::GetList(array(), array("ID" => $arg2["PRODUCT_ID"]), false, false, array("ID", "IBLOCK_ID"));
if ($arPriceElement = $rsPriceElement->Fetch()) {
$arCatalog = CCatalog::GetByID($arPriceElement["IBLOCK_ID"]);
if (is_array($arCatalog)) {
//Check if it is offers iblock
if ($arCatalog["OFFERS"] == "Y") {
//Find product element
$rsElement = CIBlockElement::GetProperty($arPriceElement["IBLOCK_ID"], $arPriceElement["ID"], "sort", "asc", array("ID" => $arCatalog["SKU_PROPERTY_ID"]));
$arElement = $rsElement->Fetch();
if ($arElement && $arElement["VALUE"] > 0) {
$ELEMENT_ID = $arElement["VALUE"];
$IBLOCK_ID = $arCatalog["PRODUCT_IBLOCK_ID"];
$OFFERS_IBLOCK_ID = $arCatalog["IBLOCK_ID"];
$OFFERS_PROPERTY_ID = $arCatalog["SKU_PROPERTY_ID"];
}
} elseif ($arCatalog["OFFERS_IBLOCK_ID"] > 0) {
$ELEMENT_ID = $arPriceElement["ID"];
$IBLOCK_ID = $arPriceElement["IBLOCK_ID"];
$OFFERS_IBLOCK_ID = $arCatalog["OFFERS_IBLOCK_ID"];
$OFFERS_PROPERTY_ID = $arCatalog["OFFERS_PROPERTY_ID"];
} else {
$ELEMENT_ID = $arPriceElement["ID"];
$IBLOCK_ID = $arPriceElement["IBLOCK_ID"];
$OFFERS_IBLOCK_ID = false;
$OFFERS_PROPERTY_ID = false;
}
}
}
} elseif (is_array($arg1) && $arg1["ID"] > 0 && $arg1["IBLOCK_ID"] > 0) {
//Check if iblock has offers
$arOffers = CIBlockPriceTools::GetOffersIBlock($arg1["IBLOCK_ID"]);
if (is_array($arOffers)) {
$ELEMENT_ID = $arg1["ID"];
$IBLOCK_ID = $arg1["IBLOCK_ID"];
$OFFERS_IBLOCK_ID = $arOffers["OFFERS_IBLOCK_ID"];
$OFFERS_PROPERTY_ID = $arOffers["OFFERS_PROPERTY_ID"];
}
}
if ($ELEMENT_ID) {
static $arPropCache = array();
if (!array_key_exists($IBLOCK_ID, $arPropCache)) {
//Check for MINIMAL_PRICE property
$rsProperty = CIBlockProperty::GetByID("MINIMUM_PRICE", $IBLOCK_ID);
$arProperty = $rsProperty->Fetch();
if ($arProperty) {
$arPropCache[$IBLOCK_ID] = $arProperty["ID"];
} else {
$arPropCache[$IBLOCK_ID] = false;
}
}
if ($arPropCache[$IBLOCK_ID]) {
//Compose elements filter
if ($OFFERS_IBLOCK_ID) {
$rsOffers = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $OFFERS_IBLOCK_ID, "PROPERTY_" . $OFFERS_PROPERTY_ID => $ELEMENT_ID), false, false, array("ID"));
while ($arOffer = $rsOffers->Fetch()) {
$arProductID[] = $arOffer["ID"];
}
if (!is_array($arProductID)) {
$arProductID = array($ELEMENT_ID);
}
} else {
$arProductID = array($ELEMENT_ID);
}
$minPrice = false;
$maxPrice = false;
//Get prices
$rsPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $arProductID));
while ($arPrice = $rsPrices->Fetch()) {
if (CModule::IncludeModule('currency') && $strDefaultCurrency != $arPrice['CURRENCY']) {
$arPrice["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"], $arPrice["CURRENCY"], $strDefaultCurrency);
}
$PRICE = $arPrice["PRICE"];
if ($minPrice === false || $minPrice > $PRICE) {
$minPrice = $PRICE;
}
if ($maxPrice === false || $maxPrice < $PRICE) {
$maxPrice = $PRICE;
}
}
//Save found minimal price into property
if ($minPrice !== false) {
CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, $IBLOCK_ID, array("MINIMUM_PRICE" => $minPrice, "MAXIMUM_PRICE" => $maxPrice));
}
}
}
}
示例14: getSpecificationsList
/**
* [getSpecificationsList description]
* @param int $idUser
* @return array or false
*/
function getSpecificationsList($idUser)
{
if (!CModule::IncludeModule('iblock')) {
return false;
}
global $USER;
if ($idUser) {
$IBLOCK_ID = getIblockSpecifications();
$rsUser = CUser::GetByID($idUser);
$arUser = $rsUser->Fetch();
$arSpecificationsId = $arUser["UF_SPECIFICATIONS"];
foreach ($arSpecificationsId as $key => $id) {
$arFilterSec = array('IBLOCK_ID' => $IBLOCK_ID, 'GLOBAL_ACTIVE' => 'Y', "ID" => $id);
$db_list = CIBlockSection::GetList(array("TIMESTAMP_X" => "DESC"), $arFilterSec, true);
if ($ar_result = $db_list->GetNext()) {
$ar_result["ITEMS"] = array();
$arSelect = array("NAME", "ID", "PROPERTY_PRODUCT", "PROPERTY_COUNT");
$arFilter = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SECTION_ID" => $ar_result["ID"]);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNextElement()) {
$arItem = $ob->GetFields();
$arProdSpec = getItemCart($arItem["PROPERTY_PRODUCT_VALUE"]);
if ($arProdSpec && $arItem["PROPERTY_PRODUCT_VALUE"]) {
$arItem["PRODUCT"] = $arProdSpec;
$dbPrice = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC", "SORT" => "ASC"), array("PRODUCT_ID" => $arItem["PROPERTY_PRODUCT_VALUE"]), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO"));
if ($arPrice = $dbPrice->Fetch()) {
$arDiscounts = CCatalogDiscount::GetDiscountByPrice($arPrice["ID"], $USER->GetUserGroupArray(), "N", SITE_ID);
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"], $arPrice["CURRENCY"], $arDiscounts);
$arPrice["DISCOUNT_PRICE"] = $discountPrice;
$arItem["DISCOUNT"] = $arPrice;
}
$ar_result["ITEMS"][] = $arItem;
} elseif (!$arItem["PROPERTY_PRODUCT_VALUE"]) {
$arParams["product"] = $arItem["ID"];
removeItemSpecification($arParams);
}
}
$arSections[] = $ar_result;
}
}
return $arSections;
}
return false;
}
示例15: GetXMLData
public function GetXMLData($product)
{
$arProp = array("ID" => GetMessage("ACRIT_PROP_ID"), "CODE" => GetMessage("ACRIT_PROP_CODE"), "NAME" => GetMessage("ACRIT_PROP_NAME"), "ACTIVE" => GetMessage("ACRIT_PROP_ACTIVE"), "DATE_CREATE" => GetMessage("ACRIT_PROP_DATE_CREATE"), "CREATED_BY" => GetMessage("ACRIT_PROP_CREATED_BY"), "DETAIL_PAGE_URL" => GetMessage("ACRIT_PROP_DETAIL_PAGE_URL"), "SHOW_COUNTER" => GetMessage("ACRIT_PROP_SHOW_COUNTER"), "QUANTITY" => GetMessage("ACRIT_PROP_QUANTITY"));
$params = array();
if (is_array($this->XML_DATA) && sizeof($this->XML_DATA) > 0) {
foreach ($this->XML_DATA as $xml) {
$tmp1 = explode("-", $xml['ID']);
$tmp = explode("_", $tmp1[1]);
if ($tmp[0] == "SKU") {
$ibl = $this->sku_IBLOCK_ID[$tmp1[0]];
$prop_id = $tmp[1];
$ph = CIBlockElement::GetProperty($ibl, $product["ID"], array("sort" => "asc"), array("ID" => $prop_id));
} elseif ($tmp[0] == "QUANTITY") {
if ($this->isCat) {
$tr = CCatalogProduct::GetByID($product["ID"]);
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($arProp[$xml["ID"]], true, true, $this->ENCODING), "CODE" => $xml["ID"], "VALUE" => $tr["QUANTITY"]);
}
$ph = false;
continue;
} elseif ($tmp[0] == "PRICE") {
$dbProductPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $product["ID"], "CATALOG_GROUP_ID" => $tmp[1]));
$price = 0;
$names = '';
while ($arProductPrice = $dbProductPrices->Fetch()) {
if ($arProductPrice["PRICE"] && ($arProductPrice["PRICE"] < $price || !$price)) {
$price = $arProductPrice["PRICE"];
}
$arDissizeofs = CCatalogDiscount::GetDiscountByProduct($arProductPrice["PRODUCT_ID"], array(), "N", $arProductPrice["CATALOG_GROUP_ID"], $this->LID);
foreach ($arDissizeofs as $arDissizeof) {
if ($arDissizeof["VALUE_TYPE"] == "P") {
$price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"] * $arProductPrice["PRICE"] / 100;
} else {
$price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"];
}
if ($price_buf && ($price_buf < $price || !$price)) {
$price = $price_buf;
}
}
$names = $arProductPrice["CATALOG_GROUP_NAME"];
}
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($names, true, true, $this->ENCODING), "CODE" => $xml["ID"], "VALUE" => $price);
$ph = false;
continue;
} else {
$ibl = $tmp1[0];
$prop_id = $tmp1[1];
$mxResult = CCatalogSku::GetProductInfo($product["ID"]);
if (is_array($mxResult)) {
$ph = CIBlockElement::GetProperty($ibl, $mxResult["ID"], array("sort" => "asc"), array("ID" => $prop_id));
} else {
$ph = CIBlockElement::GetProperty($ibl, $product["ID"], array("sort" => "asc"), array("ID" => $prop_id));
}
}
if (is_object($ph)) {
while ($ob = $ph->GetNext()) {
switch ($ob["PROPERTY_TYPE"]) {
case "S":
if ($ob["USER_TYPE"] == "UserID") {
$rsUser = CUser::GetByID($ob["VALUE"]);
$arUser = $rsUser->Fetch();
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($arUser["LAST_NAME"] . " " . $arUser["FIRST_NAME"], true, true, $this->ENCODING));
} else {
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
}
break;
case "L":
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE_ENUM"], true, true, $this->ENCODING));
break;
case "E":
$res = CIBlockElement::GetByID($ob["VALUE"]);
while ($ar_res = $res->GetNext()) {
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ar_res["NAME"], true, true, $this->ENCODING));
}
break;
case "G":
if ($xml['UNIT'] != "product_type") {
$res = CIBlockSection::GetByID($ob["VALUE"]);
while ($ar_res = $res->GetNext()) {
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ar_res["NAME"], true, true, $this->ENCODING));
}
break;
} else {
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
break;
}
case "F":
$db_file = CFile::GetByID($ob["VALUE"]);
while ($ar_file = $db_file->Fetch()) {
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => "http://" . $this->DOMAIN_NAME . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $ar_file["SUBDIR"] . "/" . implode("/", array_map("rawurlencode", explode("/", $ar_file["FILE_NAME"]))));
}
break;
case "N":
$params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
break;
default:
break;
}
}
}
}
//.........这里部分代码省略.........