本文整理汇总了PHP中CCatalogProduct::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProduct::GetByID方法的具体用法?PHP CCatalogProduct::GetByID怎么用?PHP CCatalogProduct::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogProduct
的用法示例。
在下文中一共展示了CCatalogProduct::GetByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recalculateStoreBalances
function recalculateStoreBalances($id)
{
global $DB;
$arFields = array();
if (COption::GetOptionString('catalog', 'default_use_store_control', 'N') != 'Y') {
return true;
}
$dbStoreProduct = CCatalogStoreProduct::GetList(array(), array("STORE_ID" => $id, "!AMOUNT" => 0), false, false, array("PRODUCT_ID", "AMOUNT"));
while ($arStoreProduct = $dbStoreProduct->Fetch()) {
$dbAmount = $DB->Query("select SUM(SP.AMOUNT) as SUM, CP.QUANTITY_RESERVED as RESERVED, CS.ACTIVE FROM b_catalog_store_product SP inner join b_catalog_product CP on SP.PRODUCT_ID = CP.ID inner join b_catalog_store CS on SP.STORE_ID = CS.ID where SP.PRODUCT_ID = " . $arStoreProduct['PRODUCT_ID'] . " and CS.ACTIVE = 'Y' group by QUANTITY_RESERVED, ACTIVE", true);
if ($arAmount = $dbAmount->Fetch()) {
$arFields["QUANTITY"] = doubleval($arAmount["SUM"] - $arAmount["RESERVED"]);
} else {
if ($arReservAmount = CCatalogProduct::GetByID($arStoreProduct['PRODUCT_ID'])) {
$arFields["QUANTITY"] = doubleval(0 - $arReservAmount["QUANTITY_RESERVED"]);
}
}
CCatalogProduct::Update($arStoreProduct["PRODUCT_ID"], $arFields);
}
return true;
}
示例2: FloatVal
?>
<td class="COLUMN_QUANTITY">
<?echo $arItem["QUANTITY"]." ".$measure?>
</td>
<?
}
if ($columnCode == "COLUMN_REMAINING_QUANTITY")
{
?>
<td class="COLUMN_REMAINING_QUANTITY">
<?
$balance = 0;
if ($arItem["MODULE"] == "catalog" && $bUseCatalog)
{
$ar_res = CCatalogProduct::GetByID($arItem["PRODUCT_ID"]);
$balance = FloatVal($ar_res["QUANTITY"]);
}
?>
<?echo $balance?>
</td>
<?
}
if ($columnCode == "COLUMN_PROPS")
{
?>
<td class="COLUMN_PROPS">
<?
if (!empty($arBasketProps[$arItem["ID"]]) && is_array($arBasketProps[$arItem["ID"]]))
{
示例3: floatval
}
if (($columnCode == "COLUMN_REMAINING_QUANTITY") || (!array_key_exists("COLUMN_REMAINING_QUANTITY", $arUserColumns) && !in_array("COLUMN_REMAINING_QUANTITY", $arShownColumns)))
{
$hidden = (!(array_key_exists("COLUMN_REMAINING_QUANTITY", $arUserColumns))) ? "style=\"display:none\"" : "";
$arShownColumns[] = "COLUMN_REMAINING_QUANTITY";
?>
<td class="COLUMN_REMAINING_QUANTITY" <?php
echo $hidden;
?>
>
<?
$balance = "0";
if ($val["MODULE"] == "catalog" && $bUseCatalog)
{
$ar_res = CCatalogProduct::GetByID($val["PRODUCT_ID"]);
$balance = floatval($ar_res["QUANTITY"]);
}
?>
<div id="DIV_BALANCE_<?php
echo $val["ID"];
?>
"><?php
echo $balance;
?>
</div>
</td>
<?
}
if (($columnCode == "COLUMN_PROPS") || (!array_key_exists("COLUMN_PROPS", $arUserColumns) && !in_array("COLUMN_PROPS", $arShownColumns)))
示例4: cancellationDocument
/**
* @param $arFields
* @return array|bool
*/
public static function cancellationDocument($arFields)
{
global $DB;
$id = intval($arFields["ID"]);
$i = 0;
$dbDocElements = CCatalogStoreDocsElement::getList(array(), array("DOC_ID" => $id));
while ($arDocElement = $dbDocElements->Fetch()) {
$arResult = array();
$arProductInfo = CCatalogProduct::GetByID($arDocElement["ELEMENT_ID"]);
$newReserved = $arProductInfo["QUANTITY_RESERVED"] + $arDocElement["AMOUNT"];
$arResult["QUANTITY_RESERVED"] = $newReserved;
$dbAmount = $DB->Query("SELECT SUM(SP.AMOUNT) as SUM, CP.QUANTITY_RESERVED as RESERVED FROM b_catalog_store_product SP INNER JOIN b_catalog_product CP ON SP.PRODUCT_ID = CP.ID INNER JOIN b_catalog_store CS ON SP.STORE_ID = CS.ID WHERE SP.PRODUCT_ID = " . $arDocElement["ELEMENT_ID"] . " AND CS.ACTIVE = 'Y' GROUP BY QUANTITY_RESERVED ", true);
if ($arAmount = $dbAmount->Fetch()) {
$arResult["QUANTITY"] = doubleval($arAmount["SUM"] - $newReserved);
if (!CCatalogProduct::Update($arDocElement["ELEMENT_ID"], $arResult)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_PURCHASING_INFO_ERROR"));
return false;
}
}
$i++;
}
if ($i > 0) {
return true;
}
return false;
}
示例5: 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");
}
}
}
}
示例6: foreach
foreach ($arAvailValueFields_names as $key => $value) {
$arResPrices[$intDiap][$value['field'] . '_' . $arProductPrice["CATALOG_GROUP_ID"]] = $arProductPrice[$value['field']];
}
$arResPrices[$intDiap]['QUANTITY_FROM'] = $arProductPrice["QUANTITY_FROM"];
$arResPrices[$intDiap]['QUANTITY_TO'] = $arProductPrice["QUANTITY_TO"];
//$arResPrices[$arResPricesMap[$arProductPrice["QUANTITY_FROM"]."-".$arProductPrice["QUANTITY_TO"]]][IntVal($arProductPrice["CATALOG_GROUP_ID"])] = $arProductPrice;
}
if (empty($arResPrices)) {
$arResPrices[] = array();
}
} else {
$arResPrices[] = array();
}
$arResProducts = array();
if ($boolCatalog && $bNeedProducts) {
$arProduct = CCatalogProduct::GetByID($arIBlockElement["ID"]);
if (!empty($arProduct)) {
foreach ($arAvailPriceFields_names as $key => $value) {
$arResProducts[$value['field']] = $arProduct[$value['field']];
}
}
}
$arResFields = array();
foreach ($arResSections as $arPath) {
foreach ($arResPrices as $arPrice) {
$arTuple = array();
foreach ($arNeedFields as $field_name) {
if (strncmp($field_name, "IE_", 3) == 0) {
$arTuple[] = $arIBlockElement["~" . substr($field_name, 3)];
} elseif (strncmp($field_name, "IP_PROP", 7) == 0) {
$arTuple[] = $arPropsValues[intval(substr($field_name, 7))];
示例7: DoubleVal
$strOfferYandex .= $strValue."\n";
}
}
}
$strOfferYandex .= "</offer>\n";
$arItem['OFFERS'][] = $strOfferYandex;
$boolItemOffers = true;
$boolItemExport = true;
}
}
if ('X' == $arCatalog['CATALOG_TYPE'] && !$boolItemOffers)
{
$arItem['CATALOG_QUANTITY'] = '';
$arItem['CATALOG_QUANTITY_TRACE'] = 'N';
$arProduct = CCatalogProduct::GetByID($arItem['ID']);
if (!empty($arProduct))
{
$arItem['CATALOG_QUANTITY'] = $arProduct['QUANTITY'];
$arItem['CATALOG_QUANTITY_TRACE'] = $arProduct['QUANTITY_TRACE'];
}
$str_QUANTITY = DoubleVal($arItem["CATALOG_QUANTITY"]);
$str_QUANTITY_TRACE = $arItem["CATALOG_QUANTITY_TRACE"];
if (($str_QUANTITY <= 0) && ($str_QUANTITY_TRACE == "Y"))
$str_AVAILABLE = ' available="false"';
else
$str_AVAILABLE = ' available="true"';
$minPrice = 0;
$minPriceRUR = 0;
$minPriceGroup = 0;
示例8: array
$ImgUrl = $productImg["src"];
}
$arPrice = CCatalogProduct::GetOptimalPrice($arItems["ID"], 1, $arBuyerGroups, "N", array(), $LID);
$arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]);
$priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
if (!is_array($arPrice["DISCOUNT"]) || count($arPrice["DISCOUNT"]) <= 0) {
$arPrice["DISCOUNT_PRICE"] = 0;
$price = $arPrice["PRICE"]["PRICE"];
} else {
$price = $arPrice["DISCOUNT_PRICE"];
}
$summaFormated = CurrencyFormatNumber($price, $arPrice["PRICE"]["CURRENCY"]);
$currentTotalPriceFormat = CurrencyFormatNumber($price, $arPrice["PRICE"]["CURRENCY"]);
$balance = 0;
$weight = 0;
if ($ar_res = CCatalogProduct::GetByID($arItems["ID"])) {
$balance = FloatVal($ar_res["QUANTITY"]);
$weight = FloatVal($ar_res["WEIGHT"]);
}
$discountPercent = 0;
if ($arPrice["DISCOUNT_PRICE"] > 0) {
$discountPercent = ($arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"]) * 100 / $arPrice["PRICE"]["PRICE"];
$discountPercent = roundEx($discountPercent, SALE_VALUE_PRECISION);
$priceDiscount = $arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"];
}
$urlEdit = "/bitrix/admin/iblock_element_edit.php?ID=" . $arItems["ID"] . "&type=" . $arItems["IBLOCK_TYPE_ID"] . "&lang=" . LANG . "&IBLOCK_ID=" . $arItems["IBLOCK_ID"] . "&find_section_section=" . IntVal($arItems["IBLOCK_SECTION_ID"]);
$arParams = array('id' => $arItems["ID"], 'name' => CUtil::JSEscape($arItems["NAME"]), 'url' => CUtil::JSEscape($arItems["DETAIL_PAGE_URL"]), 'urlImg' => CUtil::JSEscape($ImgUrl), 'urlEdit' => CUtil::JSEscape($urlEdit), 'price' => CUtil::JSEscape($price), 'priceFormated' => CUtil::JSEscape($price), 'priceBase' => CUtil::JSEscape($arPrice["PRICE"]["PRICE"]), 'priceBaseFormat' => CUtil::JSEscape($arPrice["PRICE"]["PRICE"]), 'valutaFormat' => CUtil::JSEscape($priceValutaFormat), 'priceDiscount' => CUtil::JSEscape($priceDiscount), 'summaFormated' => CUtil::JSEscape($summaFormated), 'priceTotalFormated' => CUtil::JSEscape($currentTotalPriceFormat), 'discountPercent' => CUtil::JSEscape($discountPercent), 'balance' => CUtil::JSEscape($balance), 'quantity' => floatval($arGetProduct[$arItems["ID"]]), 'module' => 'catalog', 'currency' => CUtil::JSEscape($arPrice["PRICE"]["CURRENCY"]), 'weight' => $weight, 'vatRate' => DoubleVal('0'), 'priceType' => '', 'catalogXmlID' => '', 'productXmlID' => '', 'skuProps' => CUtil::PhpToJSObject($arSkuProps), 'productProviderClass' => 'CCatalogProductProvider');
$arParams = CUtil::PhpToJSObject($arParams);
echo "FillProductFields(0, " . $arParams . ", 0);\n";
}
//end while
示例9: processAmount
protected function processAmount($element)
{
$product = \CCatalogProduct::GetByID($element['ID']);
$element['QUANTITY'] = $product['QUANTITY'];
return $element;
}
示例10: recalculateStoreBalances
function recalculateStoreBalances($id)
{
global $DB;
$arFields = array();
if (COption::GetOptionString('catalog', 'default_use_store_control', 'N') != 'Y') {
return false;
}
$dbStoreProduct = CCatalogStoreProduct::GetList(array(), array("STORE_ID" => $id, "!AMOUNT" => 0), false, false, array("PRODUCT_ID", "AMOUNT"));
while ($arStoreProduct = $dbStoreProduct->Fetch()) {
$dbAmount = $DB->Query("SELECT SUM(SP.AMOUNT) as SUM, CP.QUANTITY_RESERVED as RESERVED, CS.ACTIVE FROM b_catalog_store_product SP INNER JOIN b_catalog_product CP ON SP.PRODUCT_ID = CP.ID INNER JOIN b_catalog_store CS ON SP.STORE_ID = CS.ID WHERE SP.PRODUCT_ID = " . $arStoreProduct['PRODUCT_ID'] . " AND CS.ACTIVE = 'Y' GROUP BY QUANTITY_RESERVED, ACTIVE ", true);
if ($arAmount = $dbAmount->Fetch()) {
$arFields["QUANTITY"] = doubleval($arAmount["SUM"] - $arAmount["RESERVED"]);
} else {
if ($arReservAmount = CCatalogProduct::GetByID($arStoreProduct['PRODUCT_ID'])) {
$arFields["QUANTITY"] = doubleval(0 - $arReservAmount["QUANTITY_RESERVED"]);
}
}
if (!CCatalogProduct::Update($arStoreProduct["PRODUCT_ID"], $arFields)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_PURCHASING_INFO_ERROR"));
return false;
}
}
return true;
}
示例11: cancellationDocument
/**
* @param $documentId
* @param $userId
* @return bool
*/
public static function cancellationDocument($documentId, $userId)
{
global $DB, $APPLICATION;
$documentId = (int) $documentId;
$i = 0;
$dbDocElements = CCatalogStoreDocsElement::getList(array(), array("DOC_ID" => $documentId));
while ($arDocElement = $dbDocElements->Fetch()) {
$arResult = array();
$arProductInfo = CCatalogProduct::GetByID($arDocElement["ELEMENT_ID"]);
$newReserved = $arProductInfo["QUANTITY_RESERVED"] + $arDocElement["AMOUNT"];
$arResult["QUANTITY_RESERVED"] = $newReserved;
$dbAmount = $DB->Query("SELECT SUM(SP.AMOUNT) as SUM, CP.QUANTITY_RESERVED as RESERVED FROM b_catalog_store_product SP INNER JOIN b_catalog_product CP ON SP.PRODUCT_ID = CP.ID INNER JOIN b_catalog_store CS ON SP.STORE_ID = CS.ID WHERE SP.PRODUCT_ID = " . $arDocElement["ELEMENT_ID"] . " AND CS.ACTIVE = 'Y' GROUP BY QUANTITY_RESERVED ", true);
if ($arAmount = $dbAmount->Fetch()) {
$arResult["QUANTITY"] = doubleval($arAmount["SUM"] - $newReserved);
if (!CCatalogProduct::Update($arDocElement["ELEMENT_ID"], $arResult)) {
$APPLICATION->ThrowException(GetMessage("CAT_DOC_PURCHASING_INFO_ERROR"));
return false;
}
if (self::isNeedClearPublicCache($arProductInfo['QUANTITY'], $arResult['QUANTITY'], $arProductInfo['QUANTITY_TRACE'], $arProductInfo['CAN_BUY_ZERO'])) {
$productInfo = array('CAN_BUY_ZERO' => $arProductInfo['CAN_BUY_ZERO'], 'NEGATIVE_AMOUNT_TRACE' => $arProductInfo['NEGATIVE_AMOUNT_TRACE'], 'QUANTITY_TRACE' => $arProductInfo['QUANTITY_TRACE'], 'OLD_QUANTITY' => $arProductInfo['QUANTITY'], 'QUANTITY' => $arResult['QUANTITY'], 'DELTA' => $arResult['QUANTITY'] - $arProductInfo['QUANTITY']);
self::clearPublicCache($arProductInfo['ID'], $productInfo);
}
}
$i++;
}
return $i > 0;
}
示例12: Array
{
$DB->Commit();
}
if ($bCatalog)
{
if(
$USER->CanDoOperation('catalog_price')
&& CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit_price")
)
{
$CATALOG_QUANTITY = $arFields["CATALOG_QUANTITY"];
$CATALOG_QUANTITY_TRACE = $arFields["CATALOG_QUANTITY_TRACE"];
$CATALOG_WEIGHT = $arFields["CATALOG_WEIGHT"];
if(!CCatalogProduct::GetByID($ID))
{
$arCatalogQuantity = Array("ID" => $ID);
if(strlen($CATALOG_QUANTITY) > 0)
{
if (COption::GetOptionString("catalog", "default_use_store_control") != "Y")
$arCatalogQuantity["QUANTITY"] = $CATALOG_QUANTITY;
}
if(strlen($CATALOG_QUANTITY_TRACE) > 0)
$arCatalogQuantity["QUANTITY_TRACE"] = (($CATALOG_QUANTITY_TRACE == "Y") ? "Y" : (($CATALOG_QUANTITY_TRACE == "D") ? "D" : "N"));
if (strlen($CATALOG_WEIGHT) > 0)
$arCatalogQuantity['WEIGHT'] = $CATALOG_WEIGHT;
CCatalogProduct::Add($arCatalogQuantity);
}
else
{
示例13: 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"];
}
//.........这里部分代码省略.........
示例14: array
$arIBlocks = array();
$arResult["SEARCH"] = array();
foreach ($arResult["CATEGORIES"] as $category_id => $arCategory) {
foreach ($arCategory["ITEMS"] as $i => $arItem) {
if (isset($arItem["ITEM_ID"])) {
$arResult["SEARCH"][] =& $arResult["CATEGORIES"][$category_id]["ITEMS"][$i];
}
}
}
foreach ($arResult["SEARCH"] as $i => $arItem) {
switch ($arItem["MODULE_ID"]) {
case "iblock":
if (CModule::IncludeModule("catalog")) {
$arParams["CURRENCY"] = $arParams["CURRENCY"] ? $arParams["CURRENCY"] : CCurrency::GetBaseCurrency();
$arConvertParams = array('CURRENCY_ID' => $arParams["CURRENCY"]);
$ProductPrarams = CCatalogProduct::GetByID($arItem["ITEM_ID"]);
//echo $ProductPrarams[VAT_INCLUDED];
$arPrices = CatalogGetPriceTableEx($arItem["ITEM_ID"], 0, array(), 'Y', $arConvertParams);
unset($arResult["SEARCH"][$i]["MIN_PRICE"]);
unset($arResult["SEARCH"][$i]["PRICES"]);
foreach ($arParams["PRICE_CODE"] as $key => $prid) {
if ($arPrices["MATRIX"][$prid][0]) {
if (isset($arResult["SEARCH"][$i]["MIN_PRICE"])) {
if ($arPrices["MATRIX"][$prid][0]["ORIG_DISCOUNT_PRICE"]) {
$price_orig_val = $arPrices["MATRIX"][$prid][0]["ORIG_DISCOUNT_PRICE"];
} else {
$price_orig_val = $arPrices["MATRIX"][$prid][0]["DISCOUNT_PRICE"];
}
if ($arResult["SEARCH"][$i]["MIN_PRICE"]["DISCOUNT_PRICE"] > $price_orig_val) {
$arResult["SEARCH"][$i]["MIN_PRICE"] = $arPrices["MATRIX"][$prid][0];
}
示例15: array
$op = CSaleBasket::Add($arProduct);
//резерв
$ar_res = CCatalogProduct::GetByID($item['offer']['externalId']);
$arFields = array(
'QUANTITY' => (int)$ar_res['QUANTITY'] - (int)$item['quantity'],
'QUANTITY_RESERVED' => (int)$ar_res['QUANTITY_RESERVED'] + (int)$item['quantity'],
);
$d = CCatalogProduct::Update($item['offer']['externalId'], $arFields);
}
}
//удаляем лишние товары
foreach($bItms as $bItm){
if(!in_array($bItm['PRODUCT_ID'], $CrmItms)){
CSaleBasket::Delete($bItm['ID']);
//удаляем товары из резерва
$ar_res = CCatalogProduct::GetByID($bItm['PRODUCT_ID']);
$arFields = array(
'QUANTITY' => (int)$ar_res['QUANTITY'] + (int)$bItm['QUANTITY'],
'QUANTITY_RESERVED' => (int)$ar_res['QUANTITY_RESERVED'] - (int)$bItm['QUANTITY'],
);
$d = CCatalogProduct::Update($bItm['PRODUCT_ID'], $arFields);
}
}
if (isset($order['delivery']) === false || isset($order['delivery']['cost']) === false) {
$order['delivery']['cost'] = $arFields['PRICE_DELIVERY'];
}
if (isset($order['summ']) === false || $order['summ'] <= 0) {
$order['summ'] = $arFields['PRICE'] - $arFields['PRICE_DELIVERY'];
}