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


PHP CCatalogMeasure::getDefaultMeasure方法代码示例

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


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

示例1: getDefaultMeasure

 public static function getDefaultMeasure()
 {
     if (self::$isDefaultMeasureLoaded) {
         return self::$defaultMeasure;
     }
     if (!Main\Loader::includeModule('catalog')) {
         throw new Main\SystemException("Could not load 'catalog' module.");
     }
     self::$isDefaultMeasureLoaded = true;
     $measureFields = \CCatalogMeasure::getDefaultMeasure(true, false);
     if (!is_array($measureFields)) {
         return null;
     }
     return self::$defaultMeasure = array('ID' => intval($measureFields['ID']), 'CODE' => intval($measureFields['CODE']), 'IS_DEFAULT' => isset($measureFields['IS_DEFAULT']) && $measureFields['IS_DEFAULT'] === 'Y', 'SYMBOL' => isset($measureFields['SYMBOL_RUS']) ? $measureFields['SYMBOL_RUS'] : $measureFields['SYMBOL_INTL']);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:15,代码来源:measure.php

示例2: foreach

     }
 } else {
     foreach ($arResult["PRICES"] as &$value) {
         if (!$value['CAN_VIEW'] && !$value['CAN_BUY']) {
             continue;
         }
         $arPriceTypeID[] = $value["ID"];
     }
     if (isset($value)) {
         unset($value);
     }
 }
 $arSort = array($arParams["ELEMENT_SORT_FIELD"] => $arParams["ELEMENT_SORT_ORDER"], $arParams["ELEMENT_SORT_FIELD2"] => $arParams["ELEMENT_SORT_ORDER2"]);
 $arDefaultMeasure = array();
 if ($bIBlockCatalog) {
     $arDefaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
 }
 $currencyList = array();
 $arSections = array();
 //EXECUTE
 $rsElements = CIBlockElement::GetList($arSort, array_merge($arrFilter, $arFilter), false, $arNavParams, $arSelect);
 $rsElements->SetUrlTemplates($arParams["DETAIL_URL"]);
 if ($arParams["BY_LINK"] !== "Y" && !$arParams["SHOW_ALL_WO_SECTION"] && !$arParams["USE_MAIN_ELEMENT_SECTION"]) {
     $rsElements->SetSectionContext($arResult);
 }
 $arResult["ITEMS"] = array();
 $arMeasureMap = array();
 $arElementLink = array();
 $intKey = 0;
 while ($arItem = $rsElements->GetNext()) {
     $arItem['ID'] = (int) $arItem['ID'];
开发者ID:rasuldev,项目名称:torino,代码行数:31,代码来源:component.php

示例3: getProductDataToFillBasket

function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
	if (!\Bitrix\Main\Loader::includeModule("catalog"))
		return array();

	$arParams = array();

	$productId = (int)$productId;
	if ($productId <= 0)
	{
		return $arParams;
	}
	$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
	if ($iblockId <= 0)
	{
		return $arParams;
	}

	$arSku2Parent = array();
	$arElementId = array();

	$arElementId[] = $productId;
	$arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
	if ($arParent)
	{
		$arElementId[] = $arParent["ID"];
		$arSku2Parent[$productId] = $arParent["ID"];
	}

	$arPropertyInfo = array();
	$userColumns = (string)$userColumns;
	$arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
	foreach ($arUserColumns as $key => $column)
	{
		if (strncmp($column, 'PROPERTY_', 9) != 0)
		{
			unset($arUserColumns[$key]);
		}
		else
		{
			$propertyCode = substr($column, 9);
			if ($propertyCode == '')
			{
				unset($arUserColumns[$key]);
				continue;
			}
			$dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
			if ($arPropData = $dbres->GetNext())
				$arPropertyInfo[$column] = $arPropData;
		}
	}

	$arSelect = array_merge(
		array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
		$arUserColumns
	);

	$arProductData = getProductProps($arElementId, $arSelect);

	$defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);

	if (!empty($arProductData))
	{
		$arElementInfo = array();
		foreach ($arProductData as $elemId => &$arElement)
		{
			foreach ($arElement as $key => $value)
			{
				if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE")
				{
					$columnCode = str_replace("_VALUE", "", $key);
					$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
				}
			}
		}
		unset($arElement);

		if (isset($arProductData[$productId]))
			$arElementInfo = $arProductData[$productId];

		if (isset( $arSku2Parent[$productId]))
			$arParent = $arProductData[$arSku2Parent[$productId]];

		if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
		{
			foreach ($arUserColumns as $field)
			{
				$fieldVal = $field."_VALUE";
				$parentId = $arSku2Parent[$productId];

				if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0))
					&& (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
				{
					$arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
				}
			}
			if (strpos($arElementInfo["~XML_ID"], '#') === false)
			{
				$arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
			}
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:arteva.ru,代码行数:101,代码来源:admin_tool.php

示例4: getMeasures

function getMeasures($arBasketItems)
{
    if (Loader::includeModule('catalog')) {
        $arDefaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
        $arElementId = array();
        $basketLinks = array();
        foreach ($arBasketItems as $keyBasket => $arItem) {
            $productID = (int) $arItem["PRODUCT_ID"];
            if (!isset($basketLinks[$productID])) {
                $basketLinks[$productID] = array();
            }
            $basketLinks[$productID][] = $keyBasket;
            $arElementId[] = $productID;
            $arBasketItems[$keyBasket]['MEASURE_TEXT'] = $arDefaultMeasure['~SYMBOL_RUS'];
            $arBasketItems[$keyBasket]['MEASURE'] = 0;
        }
        unset($productID, $keyBasket, $arItem);
        if (!empty($arElementId)) {
            $arBasket2Measure = array();
            $dbres = CCatalogProduct::GetList(array(), array("ID" => $arElementId), false, false, array("ID", "MEASURE"));
            while ($arRes = $dbres->Fetch()) {
                $arRes['ID'] = (int) $arRes['ID'];
                $arRes['MEASURE'] = (int) $arRes['MEASURE'];
                if (!isset($arBasket2Measure[$arRes['MEASURE']])) {
                    $arBasket2Measure[$arRes['MEASURE']] = array();
                }
                $arBasket2Measure[$arRes['MEASURE']][] = $arRes['ID'];
            }
            unset($arRes, $dbres);
            if (!empty($arBasket2Measure)) {
                $dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => array_keys($arBasket2Measure)), false, false, array('ID', 'SYMBOL_RUS'));
                while ($arMeasure = $dbMeasure->Fetch()) {
                    $arMeasure['ID'] = (int) $arMeasure['ID'];
                    if (isset($arBasket2Measure[$arMeasure['ID']]) && !empty($arBasket2Measure[$arMeasure['ID']])) {
                        foreach ($arBasket2Measure[$arMeasure['ID']] as &$productID) {
                            if (isset($basketLinks[$productID]) && !empty($basketLinks[$productID])) {
                                foreach ($basketLinks[$productID] as &$keyBasket) {
                                    $arBasketItems[$keyBasket]['MEASURE_TEXT'] = $arMeasure['SYMBOL_RUS'];
                                    $arBasketItems[$keyBasket]['MEASURE'] = $arMeasure['ID'];
                                }
                                unset($keyBasket);
                            }
                        }
                        unset($productID);
                    }
                }
            }
        }
    }
    return $arBasketItems;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:51,代码来源:include.php

示例5: calculateSetParams

 protected function calculateSetParams($productID, $items)
 {
     global $DB;
     $quantityTrace = 'N';
     $canBuyZero = 'Y';
     $quantity = null;
     $weight = 0;
     $allItems = true;
     $tracedItems = array_filter($items, 'CCatalogProductSet::isTracedItem');
     if (empty($tracedItems)) {
         $tracedItems = $items;
     } else {
         $allItems = false;
         $quantityTrace = 'Y';
         $canBuyZero = 'N';
         foreach ($items as &$oneItem) {
             $weight += $oneItem['WEIGHT'] * $oneItem['QUANTITY_IN_SET'];
         }
         unset($oneItem);
     }
     foreach ($tracedItems as &$oneItem) {
         if ($oneItem['QUANTITY'] <= 0) {
             $itemQuantity = 0;
         } else {
             $itemQuantity = (int) floor($oneItem['QUANTITY'] / $oneItem['QUANTITY_IN_SET']);
         }
         if ($quantity === null || $quantity > $itemQuantity) {
             $quantity = $itemQuantity;
         }
         if ($allItems) {
             $weight += $oneItem['WEIGHT'] * $oneItem['QUANTITY_IN_SET'];
         }
     }
     unset($oneItem);
     $measure = CCatalogMeasure::getDefaultMeasure(true, false);
     $fields = array('WEIGHT' => $weight, 'QUANTITY' => $quantity, 'QUANTITY_TRACE' => $quantityTrace, 'CAN_BUY_ZERO' => $canBuyZero, 'NEGATIVE_AMOUNT_TRACE' => $canBuyZero, 'MEASURE' => $measure['ID'], 'TYPE' => CCatalogProduct::TYPE_SET);
     $update = $DB->PrepareUpdate('b_catalog_product', $fields);
     if (!empty($update)) {
         $query = "update b_catalog_product set " . $update . " where ID = " . $productID;
         $DB->Query($query, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
     }
     $query = "delete from b_catalog_measure_ratio where PRODUCT_ID = " . $productID;
     $DB->Query($query, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
     $fields = array('PRODUCT_ID' => $productID, 'RATIO' => 1);
     $insert = $DB->PrepareInsert('b_catalog_measure_ratio', $fields);
     $query = "insert into b_catalog_measure_ratio (" . $insert[0] . ") values(" . $insert[1] . ")";
     $DB->Query($query, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
     return true;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:49,代码来源:product_set.php

示例6: SubscribeProduct

/**
 * @param int $intProductID
 * @param array $arRewriteFields
 * @param array $arProductParams
 * @return bool|int
 */
function SubscribeProduct($intProductID, $arRewriteFields = array(), $arProductParams = array())
{
    global $USER, $APPLICATION;
    if (!CCatalog::IsUserExists()) {
        return false;
    }
    if (!$USER->IsAuthorized()) {
        return false;
    }
    $intUserID = (int) $USER->GetID();
    $intProductID = (int) $intProductID;
    if ($intProductID <= 0) {
        $APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_EMPTY_PRODUCT_ID'), "EMPTY_PRODUCT_ID");
        return false;
    }
    if (!Loader::includeModule("sale")) {
        $APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_NO_SALE_MODULE'), "NO_SALE_MODULE");
        return false;
    }
    if (Loader::includeModule("statistic") && isset($_SESSION['SESS_SEARCHER_ID']) && (int) $_SESSION["SESS_SEARCHER_ID"] > 0) {
        $APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_SESS_SEARCHER'), "SESS_SEARCHER");
        return false;
    }
    $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $intProductID), false, false, array('ID', 'WEIGHT', 'WIDTH', 'HEIGHT', 'LENGTH', 'TYPE', 'MEASURE', 'SUBSCRIBE'));
    if (!($arCatalogProduct = $rsProducts->Fetch())) {
        $APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_NO_PRODUCT'), "NO_PRODUCT");
        return false;
    }
    if ($arCatalogProduct['SUBSCRIBE'] == 'N') {
        $APPLICATION->ThrowException(Loc::getMessage('CATALOG_ERR_NO_SUBSCRIBE'), 'SUBSCRIBE');
        return false;
    }
    $arCatalogProduct['MEASURE'] = (int) $arCatalogProduct['MEASURE'];
    $arCatalogProduct['MEASURE_NAME'] = '';
    $arCatalogProduct['MEASURE_CODE'] = 0;
    if ($arCatalogProduct['MEASURE'] <= 0) {
        $arMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
        $arCatalogProduct['MEASURE_NAME'] = $arMeasure['~SYMBOL_RUS'];
        $arCatalogProduct['MEASURE_CODE'] = $arMeasure['CODE'];
    } else {
        $rsMeasures = CCatalogMeasure::getList(array(), array('ID' => $arCatalogProduct['MEASURE']), false, false, array('ID', 'SYMBOL_RUS', 'CODE'));
        if ($arMeasure = $rsMeasures->GetNext()) {
            $arCatalogProduct['MEASURE_NAME'] = $arMeasure['~SYMBOL_RUS'];
            $arCatalogProduct['MEASURE_CODE'] = $arMeasure['CODE'];
        }
    }
    $rsItems = CIBlockElement::GetList(array(), array("ID" => $intProductID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'XML_ID', 'DETAIL_PAGE_URL'));
    if (!($arProduct = $rsItems->GetNext())) {
        return false;
    }
    $arParentSku = CCatalogSku::GetProductInfo($intProductID, $arProduct['IBLOCK_ID']);
    if (!empty($arParentSku)) {
        if (strpos($arProduct["~XML_ID"], '#') === false) {
            $parentIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'XML_ID'), 'filter' => array('ID' => $arParentSku['ID'])));
            if ($parent = $parentIterator->fetch()) {
                $arProduct["~XML_ID"] = $parent['XML_ID'] . '#' . $arProduct["~XML_ID"];
            }
            unset($parent, $parentIterator);
        }
    }
    $arPrice = array('PRICE' => 0.0, 'CURRENCY' => CSaleLang::GetLangCurrency(SITE_ID), 'VAT_RATE' => 0, 'PRODUCT_PRICE_ID' => 0, 'CATALOG_GROUP_NAME' => '');
    $arBuyerGroups = $USER->GetUserGroupArray();
    $arSubscrPrice = CCatalogProduct::GetOptimalPrice($intProductID, 1, $arBuyerGroups, "N", array(), SITE_ID, array());
    if (!empty($arSubscrPrice) && is_array($arSubscrPrice)) {
        $arPrice['PRICE'] = $arSubscrPrice['DISCOUNT_PRICE'];
        $arPrice['CURRENCY'] = CCurrency::GetBaseCurrency();
        $arPrice['VAT_RATE'] = $arSubscrPrice['PRICE']['VAT_RATE'];
        $arPrice['PRODUCT_PRICE_ID'] = $arSubscrPrice["PRICE"]["ID"];
        $arPrice['CATALOG_GROUP_NAME'] = $arSubscrPrice["PRICE"]["CATALOG_GROUP_NAME"];
    }
    $arProps = array();
    $strIBlockXmlID = (string) CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID');
    if ($strIBlockXmlID !== '') {
        $arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $strIBlockXmlID);
    }
    if (!empty($arProductParams) && is_array($arProductParams)) {
        foreach ($arProductParams as &$arOneProductParams) {
            $arProps[] = array("NAME" => $arOneProductParams["NAME"], "CODE" => $arOneProductParams["CODE"], "VALUE" => $arOneProductParams["VALUE"], "SORT" => $arOneProductParams["SORT"]);
        }
        unset($arOneProductParams);
    }
    $arProps[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arProduct["XML_ID"]);
    $arFields = array("PRODUCT_ID" => $intProductID, "PRODUCT_PRICE_ID" => $arPrice['PRODUCT_PRICE_ID'], "PRICE" => $arPrice['PRICE'], "CURRENCY" => $arPrice['CURRENCY'], "WEIGHT" => $arCatalogProduct["WEIGHT"], "DIMENSIONS" => serialize(array("WIDTH" => $arCatalogProduct["WIDTH"], "HEIGHT" => $arCatalogProduct["HEIGHT"], "LENGTH" => $arCatalogProduct["LENGTH"])), "QUANTITY" => 1, "LID" => SITE_ID, "DELAY" => "N", "CAN_BUY" => "N", "SUBSCRIBE" => "Y", "NAME" => $arProduct["~NAME"], "MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "NOTES" => $arPrice["CATALOG_GROUP_NAME"], "DETAIL_PAGE_URL" => $arProduct["~DETAIL_PAGE_URL"], "CATALOG_XML_ID" => $strIBlockXmlID, "PRODUCT_XML_ID" => $arProduct["~XML_ID"], "PROPS" => $arProps, "TYPE" => $arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET ? CCatalogProductSet::TYPE_SET : NULL, "MEASURE_NAME" => $arCatalogProduct['MEASURE_NAME'], "MEASURE_CODE" => $arCatalogProduct['MEASURE_CODE'], 'IGNORE_CALLBACK_FUNC' => 'Y');
    if (!empty($arRewriteFields) && is_array($arRewriteFields)) {
        if (array_key_exists('SUBSCRIBE', $arRewriteFields)) {
            unset($arRewriteFields['SUBSCRIBE']);
        }
        if (array_key_exists('CAN_BUY', $arRewriteFields)) {
            unset($arRewriteFields['CAN_BUY']);
        }
        if (array_key_exists('DELAY', $arRewriteFields)) {
            unset($arRewriteFields['DELAY']);
        }
        if (!empty($arRewriteFields)) {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:include.php

示例7: GetDefaultMeasure

	public static function GetDefaultMeasure()
	{
		if (self::$catalogIncluded === null)
			self::$catalogIncluded = \Freetrix\Main\Loader::includeModule('catalog');
		return (self::$catalogIncluded ? array() : CCatalogMeasure::getDefaultMeasure(true, true));
	}
开发者ID:ASDAFF,项目名称:open_bx,代码行数:6,代码来源:comp_pricetools.php

示例8: getReferences

 /**
  * Get common data from cache.
  * @return mixed[]
  */
 protected function getReferences()
 {
     global $USER;
     $this->arParams['CACHE_GROUPS'] = isset($this->arParams['CACHE_GROUPS']) && $this->arParams['CACHE_GROUPS'] == 'N' ? 'N' : 'Y';
     $obCache = new CPHPCache();
     if ($this->arParams['CACHE_GROUPS'] == 'Y') {
         $cacheId = implode("-", array(__CLASS__, LANGUAGE_ID, SITE_ID, $USER->GetGroups()));
     } else {
         $cacheId = implode("-", array(__CLASS__, LANGUAGE_ID, SITE_ID));
     }
     $cached = array();
     if ($obCache->StartDataCache($this->arParams["CACHE_TIME"], $cacheId, SITE_ID . '/' . $this->getRelativePath() . '/reference')) {
         // Catalog Groups
         $cached['CATALOG_GROUP'] = array();
         $catalogGroupIterator = CCatalogGroup::GetList(array("SORT" => "ASC"));
         while ($catalogGroup = $catalogGroupIterator->fetch()) {
             $cached['CATALOG_GROUP'][$catalogGroup['NAME']] = $catalogGroup;
         }
         // Catalog Prices
         $cached['CATALOG_PRICE'] = CIBlockPriceTools::GetCatalogPrices(false, array_keys($cached['CATALOG_GROUP']));
         // Catalog Currency
         $cached['CURRENCY'] = array();
         if ($this->isCurrency) {
             $by = "currency";
             $order = "asc";
             $currencyIterator = CCurrency::getList($by, $order);
             while ($currency = $currencyIterator->fetch()) {
                 $cached['CURRENCY'][$currency['CURRENCY']] = $currency;
             }
         }
         // Catalogs list
         $cached['CATALOG'] = array();
         $catalogIterator = CCatalog::getList(array("IBLOCK_ID" => "ASC"));
         while ($catalog = $catalogIterator->fetch()) {
             $info = CCatalogSku::getInfoByIblock($catalog['IBLOCK_ID']);
             $catalog['CATALOG_TYPE'] = $info['CATALOG_TYPE'];
             $cached['CATALOG'][$catalog['IBLOCK_ID']] = $catalog;
         }
         // Measure list
         $cached['MEASURE'] = array();
         $measureIterator = CCatalogMeasure::getList(array("CODE" => "ASC"));
         while ($measure = $measureIterator->fetch()) {
             $cached['MEASURE'][$measure['ID']] = $measure;
         }
         // Default Measure
         $cached['DEFAULT_MEASURE'] = CCatalogMeasure::getDefaultMeasure(true, true);
         $obCache->EndDataCache($cached);
     } else {
         $cached = $obCache->GetVars();
     }
     return $cached;
 }
开发者ID:akniyev,项目名称:arteva.ru,代码行数:56,代码来源:class.php

示例9: getProductDataToFillBasket

 /**
  * @param $productId
  * @param $quantity
  * @param $userId
  * @param $LID
  * @param $userColumns
  * @param string $tmpId we can suggest that this mean the set_item
  * @return array
  * @throws Main\LoaderException
  */
 protected function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
 {
     $isSetItem = $tmpId != "";
     if (self::$catalogIncluded === null) {
         self::$catalogIncluded = Main\Loader::includeModule('catalog');
     }
     if (!self::$catalogIncluded) {
         return array();
     }
     $arParams = array();
     static $proxyIblockElement = array();
     static $proxyCatalogMeasure = array();
     static $proxyParent = array();
     static $proxyIblockProperty = array();
     static $proxyProductData = array();
     static $proxyCatalogProduct = array();
     static $proxyCatalogMeasureRatio = array();
     $productId = (int) $productId;
     if ($productId <= 0) {
         return $arParams;
     }
     if (!empty($proxyIblockElement[$productId])) {
         $iblockId = $proxyIblockElement[$productId];
     } else {
         $iblockId = (int) \CIBlockElement::getIBlockByID($productId);
         if ($iblockId > 0) {
             $proxyIblockElement[$productId] = $iblockId;
         }
     }
     if ($iblockId <= 0) {
         return $arParams;
     }
     $arSku2Parent = array();
     $arElementId = array();
     $arElementId[] = $productId;
     $proxyParentKey = $productId . "|" . $iblockId;
     if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey])) {
         $arParent = $proxyParent[$proxyParentKey];
     } else {
         $arParent = \CCatalogSku::getProductInfo($productId, $iblockId);
         $proxyParent[$proxyParentKey] = $arParent;
     }
     if ($arParent) {
         $arElementId[] = $arParent["ID"];
         $arSku2Parent[$productId] = $arParent["ID"];
     }
     $arPropertyInfo = array();
     $userColumns = (string) $userColumns;
     $arUserColumns = $userColumns != '' ? explode(",", $userColumns) : array();
     foreach ($arUserColumns as $key => $column) {
         if (strncmp($column, 'PROPERTY_', 9) != 0) {
             unset($arUserColumns[$key]);
         } else {
             $propertyCode = substr($column, 9);
             if ($propertyCode == '') {
                 unset($arUserColumns[$key]);
                 continue;
             }
             if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode])) {
                 $arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
             } else {
                 $dbres = \CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
                 if ($arPropData = $dbres->GetNext()) {
                     $arPropertyInfo[$column] = $arPropData;
                     $proxyIblockProperty[$propertyCode] = $arPropData;
                 }
             }
         }
     }
     $arSelect = array_merge(array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "XML_ID", "IBLOCK_XML_ID"), $arUserColumns);
     $proxyProductDataKey = md5(join('|', $arElementId) . "_" . join('|', $arSelect));
     if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey])) {
         $arProductData = $proxyProductData[$proxyProductDataKey];
     } else {
         $arProductData = getProductProps($arElementId, $arSelect);
         $proxyProductData[$proxyProductDataKey] = $arProductData;
     }
     $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true);
     if (!empty($arProductData)) {
         $arElementInfo = array();
         foreach ($arProductData as $elemId => &$arElement) {
             foreach ($arElement as $key => $value) {
                 if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE") {
                     $columnCode = str_replace("_VALUE", "", $key);
                     $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
                 }
             }
         }
         unset($arElement);
         if (isset($arProductData[$productId])) {
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:orderbasket.php

示例10: getReferences

 /**
  * Get common data from cache.
  * @return mixed[]
  */
 protected function getReferences()
 {
     $this->arParams['CACHE_GROUPS'] = isset($this->arParams['CACHE_GROUPS']) && $this->arParams['CACHE_GROUPS'] == 'N' ? 'N' : 'Y';
     $obCache = new CPHPCache();
     if ($this->arParams['CACHE_GROUPS'] == 'Y') {
         $userGroups = implode(",", Main\UserTable::getUserGroupIds($this->getUserId()));
         $cacheId = implode("-", array(__CLASS__, $this->getLanguageId(), $this->getSiteId(), $userGroups));
     } else {
         $cacheId = implode("-", array(__CLASS__, $this->getLanguageId(), $this->getSiteId()));
     }
     $cached = array();
     if ($obCache->StartDataCache($this->arParams["CACHE_TIME"], $cacheId, $this->getSiteId() . '/' . $this->getRelativePath() . '/reference')) {
         // Catalog Groups
         $cached['CATALOG_GROUP'] = array();
         $catalogGroupIterator = CCatalogGroup::GetList(array("SORT" => "ASC"));
         while ($catalogGroup = $catalogGroupIterator->fetch()) {
             $cached['CATALOG_GROUP'][$catalogGroup['NAME']] = $catalogGroup;
         }
         // Catalog Prices
         $cached['CATALOG_PRICE'] = CIBlockPriceTools::GetCatalogPrices(false, array_keys($cached['CATALOG_GROUP']));
         // Catalog Currency
         $cached['CURRENCY'] = array();
         if ($this->isCurrency) {
             $by = "currency";
             $order = "asc";
             $currencyIterator = CCurrency::getList($by, $order);
             while ($currency = $currencyIterator->fetch()) {
                 $cached['CURRENCY'][$currency['CURRENCY']] = $currency;
             }
         }
         // Catalogs list
         $cached['CATALOG'] = array();
         $catalogIterator = CCatalog::getList(array("IBLOCK_ID" => "ASC"));
         while ($catalog = $catalogIterator->fetch()) {
             $info = CCatalogSku::getInfoByIblock($catalog['IBLOCK_ID']);
             $catalog['CATALOG_TYPE'] = $info['CATALOG_TYPE'];
             $cached['CATALOG'][$catalog['IBLOCK_ID']] = $catalog;
         }
         // Measure list
         $cached['MEASURE'] = array();
         $measureIterator = CCatalogMeasure::getList(array("CODE" => "ASC"));
         while ($measure = $measureIterator->fetch()) {
             $cached['MEASURE'][$measure['ID']] = $measure;
         }
         // Default Measure
         $cached['DEFAULT_MEASURE'] = CCatalogMeasure::getDefaultMeasure(true, true);
         $additionalCache = $this->getAdditionalRefereneces();
         if (!empty($additionalCache) && is_array($additionalCache)) {
             foreach ($additionalCache as $cacheKey => $cacheData) {
                 $cached[$cacheKey] = $cacheData;
             }
             unset($cacheKey, $cacheData);
         }
         unset($additionalCache);
         $obCache->EndDataCache($cached);
     } else {
         $cached = $obCache->GetVars();
     }
     return $cached;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:64,代码来源:class.php

示例11: getMeasures

function getMeasures($arBasketItems)
{
    static $measures = array();
    $newMeasure = array();
    if (Loader::includeModule('catalog')) {
        $arDefaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
        $arElementId = array();
        $basketLinks = array();
        foreach ($arBasketItems as $keyBasket => $arItem) {
            if (isset($arItem['MEASURE_NAME']) && strlen($arItem['MEASURE_NAME']) > 0) {
                $measureText = $arItem['MEASURE_NAME'];
                $measureCode = intval($arItem['MEASURE_CODE']);
            } else {
                $productID = (int) $arItem["PRODUCT_ID"];
                if (!isset($basketLinks[$productID])) {
                    $basketLinks[$productID] = array();
                }
                $basketLinks[$productID][] = $keyBasket;
                $arElementId[] = $productID;
                $measureText = $arDefaultMeasure['~SYMBOL_RUS'];
                $measureCode = 0;
            }
            $arBasketItems[$keyBasket]['MEASURE_TEXT'] = $measureText;
            $arBasketItems[$keyBasket]['MEASURE'] = $measureCode;
        }
        unset($productID, $keyBasket, $arItem);
        if (!empty($arElementId)) {
            $arBasket2Measure = array();
            $dbres = CCatalogProduct::GetList(array(), array("ID" => $arElementId), false, false, array("ID", "MEASURE"));
            while ($arRes = $dbres->Fetch()) {
                $arRes['ID'] = (int) $arRes['ID'];
                $arRes['MEASURE'] = (int) $arRes['MEASURE'];
                if (!isset($arBasket2Measure[$arRes['MEASURE']])) {
                    $arBasket2Measure[$arRes['MEASURE']] = array();
                }
                $arBasket2Measure[$arRes['MEASURE']][] = $arRes['ID'];
                if (!isset($measures[$arRes['MEASURE']]) && !in_array($arRes['MEASURE'], $newMeasure)) {
                    $newMeasure[] = $arRes['MEASURE'];
                }
            }
            unset($arRes, $dbres);
            if (!empty($newMeasure)) {
                $dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => array_values($newMeasure)), false, false, array('ID', 'SYMBOL_RUS'));
                while ($arMeasure = $dbMeasure->Fetch()) {
                    $measures[$arMeasure['ID']] = $arMeasure;
                }
            }
            foreach ($arBasket2Measure as $measureId => $productIds) {
                foreach ($productIds as $productId) {
                    if (isset($basketLinks[$productId]) && !empty($basketLinks[$productId])) {
                        foreach ($basketLinks[$productId] as $keyBasket) {
                            $arBasketItems[$keyBasket]['MEASURE_TEXT'] = $measures[$measureId]['SYMBOL_RUS'];
                            $arBasketItems[$keyBasket]['MEASURE'] = $measures[$measureId]['ID'];
                        }
                    }
                }
            }
        }
    }
    return $arBasketItems;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:61,代码来源:include.php

示例12: GetDefaultMeasure

 public static function GetDefaultMeasure()
 {
     if (self::$catalogIncluded === null) {
         self::$catalogIncluded = Loader::includeModule('catalog');
     }
     return self::$catalogIncluded ? array() : CCatalogMeasure::getDefaultMeasure(true, true);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:7,代码来源:comp_pricetools.php

示例13: getCurrentRatioWithMeasure

 /**
  * Returns ratio and measure for products.
  *
  * @param array|int $product				Product ids.
  * @return array|bool
  * @throws Main\ArgumentException
  */
 public static function getCurrentRatioWithMeasure($product)
 {
     if (!is_array($product)) {
         $product = array($product);
     }
     Main\Type\Collection::normalizeArrayValuesByInt($product, true);
     if (empty($product)) {
         return false;
     }
     $result = array();
     $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true);
     $defaultRow = array('RATIO' => 1, 'MEASURE' => !empty($defaultMeasure) ? $defaultMeasure : array());
     $existProduct = array();
     $measureMap = array();
     $productRows = array_chunk($product, 500);
     foreach ($productRows as &$row) {
         $productIterator = self::getList(array('select' => array('ID', 'MEASURE'), 'filter' => array('@ID' => $row), 'order' => array('ID' => 'ASC')));
         while ($item = $productIterator->fetch()) {
             $item['ID'] = (int) $item['ID'];
             $item['MEASURE'] = (int) $item['MEASURE'];
             self::$existProductCache[$item['ID']] = true;
             $existProduct[] = $item['ID'];
             $result[$item['ID']] = $defaultRow;
             if ($item['MEASURE'] > 0) {
                 if (!isset($measureMap[$item['MEASURE']])) {
                     $measureMap[$item['MEASURE']] = array();
                 }
                 $measureMap[$item['MEASURE']][] =& $result[$item['ID']];
             }
         }
         unset($item, $productIterator);
     }
     unset($row, $productRows);
     unset($defaultRow, $defaultMeasure);
     if (empty($existProduct)) {
         return false;
     }
     $ratioResult = MeasureRatioTable::getCurrentRatio($existProduct);
     if (!empty($ratioResult)) {
         foreach ($ratioResult as $ratioProduct => $ratio) {
             $result[$ratioProduct]['RATIO'] = $ratio;
         }
         unset($ratio, $ratioProduct);
     }
     unset($ratioResult);
     unset($existProduct);
     if (!empty($measureMap)) {
         $measureIterator = \CCatalogMeasure::getList(array(), array('@ID' => array_keys($measureMap)), false, false, array());
         while ($measure = $measureIterator->getNext()) {
             $measure['ID'] = (int) $measure['ID'];
             if (empty($measureMap[$measure['ID']])) {
                 continue;
             }
             foreach ($measureMap[$measure['ID']] as &$product) {
                 $product['MEASURE'] = $measure;
             }
             unset($product);
         }
         unset($measure, $measureIterator);
     }
     unset($measureMap);
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:70,代码来源:product.php


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