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


PHP CCatalogProduct::GetById方法代码示例

本文整理汇总了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"];
//.........这里部分代码省略.........
开发者ID:nProfessor,项目名称:Mytb,代码行数:101,代码来源:cml2.php

示例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"])));
                 }
开发者ID:nycmic,项目名称:bittest,代码行数:67,代码来源:cml2.php

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


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