本文整理汇总了PHP中CCatalogProduct::GetById方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProduct::GetById方法的具体用法?PHP CCatalogProduct::GetById怎么用?PHP CCatalogProduct::GetById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogProduct
的用法示例。
在下文中一共展示了CCatalogProduct::GetById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImportElementPrices
function ImportElementPrices($arXMLElement, &$counter)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
static $catalogs = array();
$arElement = array(
"ID" => 0,
"XML_ID" => $arXMLElement[GetMessage("IBLOCK_XML2_ID")],
);
$hashPosition = strrpos($arElement["XML_ID"], "#");
if (
$this->use_offers
&& $hashPosition === false
&& isset($this->PROPERTY_MAP["CML2_LINK"])
&& isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]])
)
{
$IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"];
if (!isset($catalogs[$IBLOCK_ID]))
{
$catalogs[$IBLOCK_ID] = true;
$rs = CCatalog::GetList(array(),array("IBLOCK_ID" => $IBLOCK_ID));
if (!$rs->Fetch())
{
$obCatalog = new CCatalog();
$boolFlag = $obCatalog->Add(array(
"IBLOCK_ID" => $IBLOCK_ID,
"YANDEX_EXPORT" => "N",
"SUBSCRIPTION" => "N",
));
if (!$boolFlag)
{
if ($ex = $APPLICATION->GetException())
$this->LAST_ERROR = $ex->GetString();
return 0;
}
}
}
}
else
{
$IBLOCK_ID = $this->next_step["IBLOCK_ID"];
}
$obElement = new CIBlockElement;
$rsElement = $obElement->GetList(
Array("ID"=>"asc"),
Array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID),
false, false,
Array("ID", "TMP_ID", "ACTIVE")
);
if($arDBElement = $rsElement->Fetch())
{
$arElement["ID"] = $arDBElement["ID"];
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")]))
{//Collect price information for future use
$arElement["PRICES"] = array();
foreach($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")] as $price)
{
if(
isset($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")])
&& array_key_exists($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")], $this->PRICES_MAP)
)
{
$price["PRICE"] = $this->PRICES_MAP[$price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]];
$arElement["PRICES"][] = $price;
}
}
$arElement["DISCOUNTS"] = array();
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")]))
{
foreach($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")] as $discount)
{
if(
isset($discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")])
&& $discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")] === GetMessage("IBLOCK_XML2_DISCOUNT_COND_VOLUME")
)
{
$discount_value = $this->ToInt($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_VALUE")]);
$discount_percent = $this->ToFloat($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_PERCENT")]);
if($discount_value > 0 && $discount_percent > 0)
$arElement["DISCOUNTS"][$discount_value] = $discount_percent;
}
}
}
}
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_AMOUNT")]))
{
$arElementTmp = array();
$arElement["QUANTITY_RESERVED"] = 0;
if($arElement["ID"])
$arElementTmp = CCatalogProduct::GetById($arElement["ID"]);
if(is_array($arElementTmp) && !empty($arElementTmp) && isset($arElementTmp["QUANTITY_RESERVED"]))
$arElement["QUANTITY_RESERVED"] = $arElementTmp["QUANTITY_RESERVED"];
//.........这里部分代码省略.........
示例2: ImportElementPrices
//.........这里部分代码省略.........
if ($arDBElement) {
$arProduct = array("ID" => $arElement["ID"]);
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]])) {
$arElement["PRICES"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]] as $price) {
if (isset($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]) && array_key_exists($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]], $this->PRICES_MAP)) {
$price["PRICE"] = $this->PRICES_MAP[$price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]];
$arElement["PRICES"][] = $price;
if (array_key_exists($this->mess["IBLOCK_XML2_MEASURE"], $price) && !isset($arProduct["MEASURE"])) {
$tmp = $this->convertBaseUnitFromXmlToPropertyValue($price[$this->mess["IBLOCK_XML2_MEASURE"]]);
if ($tmp["DESCRIPTION"] > 0) {
$arProduct["MEASURE"] = $tmp["DESCRIPTION"];
}
}
}
}
$arElement["DISCOUNTS"] = array();
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]])) {
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]] as $discount) {
if (isset($discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]]) && $discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]] === $this->mess["IBLOCK_XML2_DISCOUNT_COND_VOLUME"]) {
$discount_value = $this->ToInt($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_VALUE"]]);
$discount_percent = $this->ToFloat($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_PERCENT"]]);
if ($discount_value > 0 && $discount_percent > 0) {
$arElement["DISCOUNTS"][$discount_value] = $discount_percent;
}
}
}
}
}
if (array_key_exists($this->mess["IBLOCK_XML2_AMOUNT"], $arXMLElement)) {
$arElementTmp = array();
$arElement["QUANTITY_RESERVED"] = 0;
if ($arElement["ID"]) {
$arElementTmp = CCatalogProduct::GetById($arElement["ID"]);
}
if (is_array($arElementTmp) && !empty($arElementTmp) && isset($arElementTmp["QUANTITY_RESERVED"])) {
$arElement["QUANTITY_RESERVED"] = $arElementTmp["QUANTITY_RESERVED"];
}
$arElement["QUANTITY"] = $this->ToFloat($arXMLElement[$this->mess["IBLOCK_XML2_AMOUNT"]]) - doubleval($arElement["QUANTITY_RESERVED"]);
}
if (isset($arElement["PRICES"]) && $this->bCatalog) {
if (isset($arElement["QUANTITY"])) {
$arProduct["QUANTITY"] = $arElement["QUANTITY"];
} elseif (isset($arElement["STORE_AMOUNT"]) && !empty($arElement["STORE_AMOUNT"])) {
$arProduct["QUANTITY"] = array_sum($arElement["STORE_AMOUNT"]);
}
$rsWeight = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array(), array("CODE" => "CML2_TRAITS"));
while ($arWeight = $rsWeight->Fetch()) {
if ($arWeight["DESCRIPTION"] == $this->mess["IBLOCK_XML2_WEIGHT"]) {
$arProduct["WEIGHT"] = $this->ToFloat($arWeight["VALUE"]) * 1000;
}
}
$rsUnit = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array(), array("CODE" => "CML2_BASE_UNIT"));
while ($arUnit = $rsUnit->Fetch()) {
if ($arUnit["DESCRIPTION"] > 0) {
$arProduct["MEASURE"] = $arUnit["DESCRIPTION"];
}
}
//Here start VAT handling
//Check if all the taxes exists in BSM catalog
$arTaxMap = array();
$rsTaxProperty = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array("sort" => "asc"), array("CODE" => "CML2_TAXES"));
while ($arTaxProperty = $rsTaxProperty->Fetch()) {
if (strlen($arTaxProperty["VALUE"]) > 0 && strlen($arTaxProperty["DESCRIPTION"]) > 0 && !array_key_exists($arTaxProperty["DESCRIPTION"], $arTaxMap)) {
$arTaxMap[$arTaxProperty["DESCRIPTION"]] = array("RATE" => $this->ToFloat($arTaxProperty["VALUE"]), "ID" => $this->CheckTax($arTaxProperty["DESCRIPTION"], $this->ToFloat($arTaxProperty["VALUE"])));
}
示例3: foreach
foreach ($_POST["PRODUCT"] as $product) {
?>
var arBarCodes = new Array();
<?php
if (is_array($product["BAR_CODE"])) {
foreach ($product["BAR_CODE"] as $barCode) {
?>
arBarCodes.push(<?php
echo $barCode;
?>
);
<?php
}
$product["BAR_CODE"] = '';
}
$reserved = CCatalogProduct::GetById($product["PRODUCT_ID"]);
$reserved = $reserved["QUANTITY_RESERVED"];
?>
FillProductFields(1, {
'id': "<?php
echo $product["PRODUCT_ID"];
?>
",
'module': "<?php
echo $product["MODULE"];
?>
",
'name': "<?php
echo $product["NAME"];
?>
",