本文整理汇总了PHP中CCatalogSKU::getProductList方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogSKU::getProductList方法的具体用法?PHP CCatalogSKU::getProductList怎么用?PHP CCatalogSKU::getProductList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogSKU
的用法示例。
在下文中一共展示了CCatalogSKU::getProductList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBasketItems
public function getBasketItems()
{
global $APPLICATION;
if (self::$catalogIncluded === null) {
self::$catalogIncluded = Loader::includeModule('catalog');
}
self::$iblockIncluded = self::$catalogIncluded;
CSaleBasket::UpdateBasketPrices(CSaleBasket::GetBasketUserID(), SITE_ID);
$bShowReady = false;
$bShowDelay = false;
$bShowSubscribe = false;
$bShowNotAvail = false;
$allSum = 0;
$allWeight = 0;
$allCurrency = CSaleLang::GetLangCurrency(SITE_ID);
$allVATSum = 0;
$arParents = array();
$arResult["ITEMS"]["AnDelCanBuy"] = array();
$arResult["ITEMS"]["DelDelCanBuy"] = array();
$arResult["ITEMS"]["nAnCanBuy"] = array();
$arResult["ITEMS"]["ProdSubscribe"] = array();
$DISCOUNT_PRICE_ALL = 0;
// BASKET PRODUCTS (including measures, ratio, iblock properties data)
$arImgFields = array("PREVIEW_PICTURE", "DETAIL_PICTURE");
$arBasketItems = array();
$basketKey = 0;
$basketIds = array();
$arSku2Parent = array();
$arSetParentWeight = array();
$arElementId = array();
$dbItems = CSaleBasket::GetList(array("ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "DETAIL_PAGE_URL", "NOTES", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID", "PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"));
while ($arItem = $dbItems->GetNext()) {
$arItem['PROPS'] = array();
$arBasketItems[$basketKey] = $arItem;
$basketIds[$arItem['ID']] =& $arBasketItems[$basketKey];
$basketKey++;
if (CSaleBasketHelper::isSetItem($arItem)) {
continue;
}
$arElementId[] = $arItem["PRODUCT_ID"];
}
if (!empty($arElementId) && self::$catalogIncluded) {
$productList = CCatalogSKU::getProductList($arElementId);
if (!empty($productList)) {
foreach ($productList as $offerId => $offerInfo) {
$offerInfo['PRODUCT_ID'] = $offerInfo['ID'];
$arElementId[] = $offerInfo['ID'];
$arSku2Parent[$offerId] = $offerInfo['ID'];
$arParents[$offerId] = $offerInfo;
}
unset($offerInfo, $offerId);
}
unset($productList);
// get measures, ratio, sku props data and available quantity
$arBasketItems = getMeasures($arBasketItems);
$arBasketItems = getRatio($arBasketItems);
$arBasketItems = $this->getAvailableQuantity($arBasketItems);
$propsIterator = CSaleBasket::GetPropsList(array('BASKET_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC'), array('BASKET_ID' => array_keys($basketIds)));
while ($property = $propsIterator->GetNext()) {
$property['CODE'] = (string) $property['CODE'];
if ($property['CODE'] == 'CATALOG.XML_ID' || $property['CODE'] == 'PRODUCT.XML_ID') {
continue;
}
if (!isset($basketIds[$property['BASKET_ID']])) {
continue;
}
$basketIds[$property['BASKET_ID']]['PROPS'][] = $property;
}
unset($property, $propsIterator, $basketIds);
}
// get product properties data
$arProductData = getProductProps($arElementId, array_merge(array("ID"), $arImgFields, $this->arCustomSelectFields));
foreach ($arBasketItems as &$arItem) {
$quantityIsFloat = false;
if (number_format(doubleval($arItem['QUANTITY']), 2, '.', '') != intval($arItem['QUANTITY'])) {
$quantityIsFloat = true;
}
$arItem["QUANTITY"] = $quantityIsFloat === false && $this->quantityFloat != "Y" ? intval($arItem['QUANTITY']) : number_format(doubleval($arItem['QUANTITY']), 2, '.', '');
$arItem["PRICE_VAT_VALUE"] = $arItem["PRICE"] / ($arItem["VAT_RATE"] + 1) * $arItem["VAT_RATE"];
$arItem["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"], $arItem["CURRENCY"], true);
$arItem["WEIGHT"] = doubleval($arItem["WEIGHT"]);
$arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
if (CSaleBasketHelper::isSetItem($arItem)) {
$arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
}
if (isset($arProductData[$arItem['PRODUCT_ID']]) && is_array($arProductData[$arItem['PRODUCT_ID']])) {
foreach ($arProductData[$arItem["PRODUCT_ID"]] as $key => $value) {
if (strpos($key, "PROPERTY_") !== false || in_array($key, $arImgFields)) {
$arItem[$key] = $value;
}
}
}
if (array_key_exists($arItem["PRODUCT_ID"], $arSku2Parent)) {
$arFieldsToFill = array_merge($this->arCustomSelectFields, $arImgFields);
// fields to be filled with parents' values if empty
foreach ($arFieldsToFill as $field) {
$fieldVal = in_array($field, $arImgFields) ? $field : $field . "_VALUE";
$parentId = $arSku2Parent[$arItem["PRODUCT_ID"]];
if ((!isset($arItem[$fieldVal]) || isset($arItem[$fieldVal]) && strlen($arItem[$fieldVal]) == 0) && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) {
$arItem[$fieldVal] = $arProductData[$parentId][$fieldVal];
//.........这里部分代码省略.........
示例2: getProductsMap
/**
* Returns ids map: SKU_PRODUCT_ID => PRODUCT_ID.
*
* @param array $originalIds Input products ids.
* @return array
*/
public static function getProductsMap(array $originalIds = array())
{
if (empty($originalIds) && !is_array($originalIds)) {
return array();
}
$result = array();
$productList = \CCatalogSKU::getProductList($originalIds);
if ($productList === false) {
$productList = array();
}
foreach ($originalIds as &$oneId) {
$result[$oneId] = isset($productList[$oneId]) ? $productList[$oneId]['ID'] : $oneId;
}
unset($oneId, $productList);
return $result;
}