本文整理汇总了PHP中CCatalogSku::GetProductInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogSku::GetProductInfo方法的具体用法?PHP CCatalogSku::GetProductInfo怎么用?PHP CCatalogSku::GetProductInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogSku
的用法示例。
在下文中一共展示了CCatalogSku::GetProductInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetProductSkuProps
static function GetProductSkuProps($ID, $IBLOCK_ID = '', $getExt = false)
{
$getExt = $getExt === true;
$arSkuProps = array();
$ID = (int) $ID;
$IBLOCK_ID = (int) $IBLOCK_ID;
if ($ID > 0 && \Bitrix\Main\Loader::includeModule('catalog')) {
$filter = array('ID' => $ID, 'ACTIVE' => 'Y');
if ($IBLOCK_ID > 0) {
$filter['IBLOCK_ID'] = $IBLOCK_ID;
}
$res = CIBlockElement::GetList(array(), $filter, false, false, array("ID", "IBLOCK_ID"));
$arElement = $res->Fetch();
if ($arElement) {
$arElement['ID'] = (int) $arElement['ID'];
$arParent = CCatalogSku::GetProductInfo($ID, $arElement["IBLOCK_ID"]);
if ($arParent) {
$arElement['PROPERTIES'] = array();
$arElementLink = array($arElement['ID'] => &$arElement);
$arFilter = array('ID' => $arElement['ID'], 'IBLOCK_ID' => $arElement["IBLOCK_ID"]);
CIBlockElement::GetPropertyValuesArray($arElementLink, $arElement["IBLOCK_ID"], $arFilter);
if (!empty($arElement['PROPERTIES'])) {
foreach ($arElement['PROPERTIES'] as &$prop) {
if ($prop['XML_ID'] == 'CML2_LINK' || $prop['PROPERTY_TYPE'] == 'F') {
continue;
}
$boolArr = is_array($prop["VALUE"]);
if ($boolArr && !empty($prop["VALUE"]) || !$boolArr && strlen($prop["VALUE"]) > 0) {
$displayProperty = CIBlockFormatProperties::GetDisplayValue($arElement, $prop, '');
$mxValues = '';
if ('E' == $prop['PROPERTY_TYPE']) {
if (!empty($displayProperty['LINK_ELEMENT_VALUE'])) {
$mxValues = array();
foreach ($displayProperty['LINK_ELEMENT_VALUE'] as $arTempo) {
$mxValues[] = $arTempo['NAME'] . ' [' . $arTempo['ID'] . ']';
}
}
} elseif ('G' == $prop['PROPERTY_TYPE']) {
if (!empty($displayProperty['LINK_SECTION_VALUE'])) {
$mxValues = array();
foreach ($displayProperty['LINK_SECTION_VALUE'] as $arTempo) {
$mxValues[] = $arTempo['NAME'] . ' [' . $arTempo['ID'] . ']';
}
}
}
if (empty($mxValues)) {
$mxValues = $displayProperty["DISPLAY_VALUE"];
}
if ($getExt) {
$arSkuProps[$prop["ID"]] = array('ID' => $prop["ID"], 'CODE' => $prop['CODE'], 'NAME' => $prop["NAME"], 'VALUE' => strip_tags(is_array($mxValues) ? implode("/ ", $mxValues) : $mxValues));
} else {
$arSkuProps[$prop["NAME"]] = strip_tags(is_array($mxValues) ? implode("/ ", $mxValues) : $mxValues);
}
}
}
unset($prop);
}
}
}
}
return $arSkuProps;
}
示例2: GetProductSkuProps
static function GetProductSkuProps($ID, $IBLOCK_ID = '')
{
$arSkuProps = array();
if (CModule::IncludeModule('iblock') && CModule::IncludeModule('catalog')) {
if (IntVal($IBLOCK_ID) <= 0) {
$res = CIBlockElement::GetList(array(), array("ID" => $ID), false, false, array("IBLOCK_ID"));
$arElement = $res->Fetch();
$IBLOCK_ID = $arElement["IBLOCK_ID"];
}
$arOfferProperties = array();
$arOfferPropsValue = array();
$arFilter = array("ID" => $ID, "IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y");
$arSelect = array("ID" => 1, "IBLOCK_ID" => 1);
$arParent = CCatalogSku::GetProductInfo($ID);
if ($arParent) {
if (!is_array($arOfferProperties[$IBLOCK_ID]) || count($arOfferProperties[$IBLOCK_ID]) <= 0) {
$dbOfferProperties = CIBlock::GetProperties($IBLOCK_ID, array(), array("!XML_ID" => "CML2_LINK"));
while ($arTmp = $dbOfferProperties->Fetch()) {
$arOfferProperties[$IBLOCK_ID][] = $arTmp;
$arSelect["PROPERTY_" . $arTmp["CODE"]] = 1;
}
}
$rsOffers = CIBlockElement::GetList(array("SORT" => "ASC"), $arFilter, false, false, array_keys($arSelect));
while ($obOffer = $rsOffers->GetNextElement()) {
$arOfferPropsValue[$ID] = $obOffer->fields;
}
if (is_array($arOfferProperties[$IBLOCK_ID]) && count($arOfferProperties[$IBLOCK_ID]) > 0) {
foreach ($arOfferProperties[$IBLOCK_ID] as $val) {
$arSkuProps[$val["NAME"]] = $arOfferPropsValue[$ID]["PROPERTY_" . $val["CODE"] . "_VALUE"];
}
}
}
}
return $arSkuProps;
}
示例3: GetProductSkuProps
static function GetProductSkuProps($ID, $IBLOCK_ID = '')
{
$arSkuProps = array();
if (CModule::IncludeModule('iblock') && CModule::IncludeModule('catalog'))
{
$res = CIBlockElement::GetList(
array(),
array(
"ID" => $ID,
"ACTIVE" => "Y",
),
false,
false,
array(
"ID",
"IBLOCK_ID",
)
);
$arElement = $res->Fetch();
if ($arElement)
{
$IBLOCK_ID = $arElement["IBLOCK_ID"];
$arParent = CCatalogSku::GetProductInfo($ID);
if ($arParent)
{
$rsOffers = CIBlockElement::GetProperty(
$IBLOCK_ID,
$ID
);
while ($arOffer = $rsOffers->GetNext())
{
if ($arOffer["XML_ID"] != "CML2_LINK")
{
if ($arOffer["PROPERTY_TYPE"] == "L")
$arSkuProps[$arOffer["NAME"]] = $arOffer["VALUE_ENUM"];
else
$arSkuProps[$arOffer["NAME"]] = $arOffer["VALUE"];
}
}
}
}
}
return $arSkuProps;
}
示例4: GetMessage
echo GetMessage('SPOL_PAYSYSTEM');
?>
:</strong> <?php
echo $arResult["INFO"]["PAY_SYSTEM"][$order["ORDER"]["PAY_SYSTEM_ID"]]["NAME"];
?>
<br /> -->
<?endif?>
<!-- <strong><?php
echo GetMessage('SPOL_BASKET');
?>
:</strong> -->
<table style="width: 100%">
<?foreach ($order["BASKET_ITEMS"] as $item): ?>
<?
$product = CCatalogSku::GetProductInfo($item['PRODUCT_ID']);
if (false === $product) {
$element = CIBlockElement::GetById($item['PRODUCT_ID'])->Fetch();
} else {
$element = CIBlockElement::GetById($product['ID'])->Fetch();
}
$item['DETAIL_PAGE_URL'] = '/butik/' . $element['CODE'] .'/';
$item['PREVIEW_PICTURE'] = CFile::ResizeImageGet($element['PREVIEW_PICTURE'], array('width' => 100, 'height' => 100));
?>
<tr>
<td style="width: 30%">
<a href="<?php
echo $item["DETAIL_PAGE_URL"];
?>
" target="_blank">
<img src="<?php
示例5: foreach
}
}
foreach ($arResult["ITEMS"]["nAnCanBuy"] as $key => $val) {
if ($arResult["ITEMS_IMG"][$val["ID"]]) {
$arResult["ITEMS"]["nAnCanBuy"][$key]["DETAIL_PICTURE"] = $arResult["ITEMS_IMG"][$val["ID"]];
}
if ($productId = CCatalogSku::GetProductInfo($val["PRODUCT_ID"])) {
$arElementsID[] = $productId["ID"];
$arProductsToElements[$productId["ID"]][] = $val["PRODUCT_ID"];
}
}
foreach ($arResult["ITEMS"]["ProdSubscribe"] as $key => $val) {
if ($arResult["ITEMS_IMG"][$val["ID"]]) {
$arResult["ITEMS"]["ProdSubscribe"][$key]["DETAIL_PICTURE"] = $arResult["ITEMS_IMG"][$val["ID"]];
}
if ($productId = CCatalogSku::GetProductInfo($val["PRODUCT_ID"])) {
$arElementsID[] = $productId["ID"];
$arProductsToElements[$productId["ID"]][] = $val["PRODUCT_ID"];
}
}
$arElementsID = array_unique($arElementsID);
$db_res = CIBlockElement::GetList(array("SORT" => "ASC"), array("ID" => $arElementsID), false, false, array("ID", "IBLOCK_ID", "DETAIL_PAGE_URL", "DETAIL_PICTURE", "PREVIEW_PICTURE"));
while ($arElement = $db_res->GetNext()) {
foreach ($arResult["ITEMS"]["AnDelCanBuy"] as $key => $val) {
if ($arProductsToElements && in_array($val["PRODUCT_ID"], $arProductsToElements[$arElement["ID"]])) {
$arResult["ITEMS"]["AnDelCanBuy"][$key]["DETAIL_PAGE_URL"] = $arElement["DETAIL_PAGE_URL"];
if (!$arResult["ITEMS"]["AnDelCanBuy"][$key]["DETAIL_PICTURE"]["SRC"]) {
if (!$arResult["ITEMS"]["AnDelCanBuy"][$key]["PREVIEW_PICTURE"]["SRC"]) {
$img = array();
if ($arElement["DETAIL_PICTURE"]) {
$img = CFile::ResizeImageGet($arElement["DETAIL_PICTURE"], array("width" => "60", "height" => "60"));
示例6: 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"];
}
//.........这里部分代码省略.........
示例7: GetMessage
}
}
if ($bErrorField) {
$arResult["ERROR"][] = GetMessage("SOA_ERROR_REQUIRE") . " \"" . $arOrderProps["NAME"] . "\"";
}
//}//end isset
}
//end while
}
/* Check Values End */
// get properties for iblock elements and their parents (if any)
$arSelect = array_merge(array("ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "PREVIEW_TEXT"), $arCustomSelectFields);
$arProductData = getProductProps($arElementId, $arSelect);
foreach ($arResult["BASKET_ITEMS"] as &$arResultItem) {
$productId = $arResultItem["PRODUCT_ID"];
$arParent = CCatalogSku::GetProductInfo($productId);
if (intval($arProductData[$productId]["PREVIEW_PICTURE"]) <= 0 && intval($arProductData[$productId]["DETAIL_PICTURE"]) <= 0 && $arParent) {
$productId = $arParent["ID"];
}
if (intval($arProductData[$productId]["PREVIEW_PICTURE"]) > 0) {
$arResultItem["PREVIEW_PICTURE"] = $arProductData[$productId]["PREVIEW_PICTURE"];
}
if (intval($arProductData[$productId]["DETAIL_PICTURE"]) > 0) {
$arResultItem["DETAIL_PICTURE"] = $arProductData[$productId]["DETAIL_PICTURE"];
}
if (strlen($arProductData[$productId]["PREVIEW_TEXT"]) > 0) {
$arResultItem["PREVIEW_TEXT"] = $arProductData[$productId]["PREVIEW_TEXT"];
}
foreach ($arProductData[$arResultItem["PRODUCT_ID"]] as $key => $value) {
if (strpos($key, "PROPERTY_") !== false) {
$arResultItem[$key] = $value;
示例8: elseif
$arFilter["FUSER_ID"] = CSaleBasket::GetBasketUserID();
$arGroups = $USER->GetUserGroupArray();
//add to busket
if (array_key_exists($arParams["ACTION_VARIABLE"], $_REQUEST) && array_key_exists($arParams["PRODUCT_ID_VARIABLE"], $_REQUEST)) {
if (array_key_exists($arParams["ACTION_VARIABLE"] . "BUY", $_REQUEST)) {
$action = "BUY";
} elseif (array_key_exists($arParams["ACTION_VARIABLE"] . "ADD2BASKET", $_REQUEST)) {
$action = "ADD2BASKET";
} else {
$action = ToUpper($_REQUEST[$arParams["ACTION_VARIABLE"]]);
}
$productID = intval($_REQUEST[$arParams["PRODUCT_ID_VARIABLE"]]);
//get props sku
$product_properties = array();
$arPropsSku = array();
$arParentSku = CCatalogSku::GetProductInfo($productID);
if ($arParentSku && count($arParentSku) > 0) {
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $productID), false, false, array('IBLOCK_ID', 'IBLOCK_SECTION_ID'));
$arProduct = $dbProduct->Fetch();
$dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
while ($arOfferProperties = $dbOfferProperties->Fetch()) {
$arPropsSku[] = $arOfferProperties["CODE"];
}
$product_properties = CIBlockPriceTools::GetOfferProperties($productID, $arParentSku["IBLOCK_ID"], $arPropsSku);
}
if (($action == "ADD2BASKET" || $action == "BUY") && $productID > 0) {
if (CModule::IncludeModule('catalog')) {
Add2BasketByProductID($productID, 1, array(), $product_properties);
}
if ($action == "BUY") {
LocalRedirect($arParams["BASKET_URL"]);
示例9: array
}
if (!empty($arFieldsTmp) && is_array($arFieldsTmp))
{
$arFields = array(
'PRODUCT_ID' => $newProductId,
'PRODUCT_PRICE_ID' => $arFieldsTmp["PRODUCT_PRICE_ID"],
'PRICE' => $arFieldsTmp["PRICE"],
'CURRENCY' => $arFieldsTmp["CURRENCY"],
'QUANTITY' => $arFieldsTmp['QUANTITY'],
'WEIGHT' => $arFieldsTmp['WEIGHT'],
);
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $newProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID','XML_ID'));
if ($arProduct = $dbProduct->Fetch())
{
$arParentSku = CCatalogSku::GetProductInfo($newProductId, $arElement["IBLOCK_ID"]);
if ($arParentSku && !empty($arParentSku))
{
$arProps = array();
if (strpos($arProduct["XML_ID"], '#') === false)
{
$dbParentProduct = CIBlockElement::GetList(array(), array("ID" => $arParentSku['ID']), false, false, array('ID','XML_ID'));
if ($arParentProduct = $dbParentProduct->Fetch())
{
$arProduct["XML_ID"] = $arParentProduct['XML_ID'].'#'.$arProduct["XML_ID"];
}
}
$arFields["PRODUCT_XML_ID"] = $arProduct["XML_ID"];
$dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
示例10: getBasketItems
public function getBasketItems()
{
global $APPLICATION;
$bUseCatalog = CModule::IncludeModule("catalog");
$bUseIblock = $bUseCatalog;
$bShowReady = False;
$bShowDelay = False;
$bShowSubscribe = False;
$bShowNotAvail = False;
$allSum = 0;
$allWeight = 0;
$allCurrency = CSaleLang::GetLangCurrency($this->getSiteId());
$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();
$arSku2Parent = array();
$arSetParentWeight = array();
$basketItemsFilter = array("USER_ID" => $this->userId, "ORDER_ID" => "NULL");
if ($this->showDelay != 'Y') {
$basketItemsFilter['DELAY'] = 'N';
}
$dbItems = CSaleBasket::GetList(array("ID" => "ASC"), $basketItemsFilter, 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()) {
$arBasketItems[] = $arItem;
if (CSaleBasketHelper::isSetItem($arItem)) {
continue;
}
$arElementId[] = $arItem["PRODUCT_ID"];
if ($bUseCatalog) {
$arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
if ($arParent) {
$arElementId[] = $arParent["ID"];
$arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"];
$arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"] = $arParent["ID"];
$arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"] = $arParent["IBLOCK_ID"];
}
}
}
// get measures, ratio, sku props data and available quantity
if (!empty($arBasketItems) && $bUseCatalog) {
$arBasketItems = getMeasures($arBasketItems);
$arBasketItems = getRatio($arBasketItems);
$arBasketItems = $this->getAvailableQuantity($arBasketItems);
}
// 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["QUANTITY_FORMATED"] = $arItem["QUANTITY"] . " " . $arItem["MEASURE_TEXT"];
$arItem["PROPS"] = array();
$dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
while ($arProp = $dbProp->GetNext()) {
$arItem["PROPS"][] = $arProp;
}
$arItem["PRICE_VAT_VALUE"] = $arItem["PRICE"] / ($arItem["VAT_RATE"] + 1) * $arItem["VAT_RATE"];
$arItem["PRICE_FORMATED"] = $this->getSaleFormatCurrency($arItem["PRICE"], $arItem["CURRENCY"]);
$arItem["WEIGHT"] = doubleval($arItem["WEIGHT"]);
$arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
$arItem["DISCOUNT_FORMATED"] = $this->getSaleFormatCurrency($arItem["DISCOUNT_PRICE"], $arItem["CURRENCY"]);
if (CSaleBasketHelper::isSetItem($arItem)) {
$arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
}
if (array_key_exists($arItem["PRODUCT_ID"], $arProductData) && 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];
}
}
}
foreach ($arItem as $key => $value) {
if (strpos($key, "PROPERTY_", 0) === 0 && strrpos($key, "_VALUE") == strlen($key) - 6) {
$code = str_replace(array("PROPERTY_", "_VALUE"), "", $key);
$propData = $this->arIblockProps[$code];
$arItem[$key] = CSaleHelper::getIblockPropInfo($value, $propData);
}
}
$arItem["PREVIEW_PICTURE_SRC"] = "";
if (isset($arItem["PREVIEW_PICTURE"]) && intval($arItem["PREVIEW_PICTURE"]) > 0) {
//.........这里部分代码省略.........
示例11: getSaleProductImage
function getSaleProductImage($product)
{
$productImg = '';
if ($product["INFO"]["PREVIEW_PICTURE"] != "") {
$productImg = $product["INFO"]["PREVIEW_PICTURE"];
} elseif ($product["INFO"]["DETAIL_PICTURE"] != "") {
$productImg = $product["INFO"]["DETAIL_PICTURE"];
}
if (empty($productImg) && CModule::IncludeModule("catalog")) {
$arParent = CCatalogSku::GetProductInfo($product["PRODUCT_ID"]);
if (intval($arParent["ID"]) > 0) {
$arProductData = getProductProps(array($arParent["ID"]), array("ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "IBLOCK_TYPE_ID", "IBLOCK_ID", "IBLOCK_SECTION_ID"));
if (!empty($arProductData[$arParent["ID"]]["PREVIEW_PICTURE"])) {
$productImg = $arProductData[$arParent["ID"]]["PREVIEW_PICTURE"];
} elseif (!empty($arProductData[$arParent["ID"]]["DETAIL_PICTURE"])) {
$productImg = $arProductData[$arParent["ID"]]["DETAIL_PICTURE"];
}
}
}
if ($productImg != "") {
$arFile = CFile::GetFileArray($productImg);
$productImg = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
}
return $productImg;
}
示例12: getBasketItems
public function getBasketItems()
{
global $APPLICATION;
$bUseCatalog = CModule::IncludeModule("catalog");
$bUseIblock = $bUseCatalog;
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();
$arSku2Parent = array();
$arSetParentWeight = 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())
{
$arBasketItems[] = $arItem;
if (CSaleBasketHelper::isSetItem($arItem))
continue;
$arElementId[] = $arItem["PRODUCT_ID"];
if ($bUseCatalog)
{
$arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
if ($arParent)
{
$arElementId[] = $arParent["ID"];
$arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"];
$arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"] = $arParent["ID"];
$arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"] = $arParent["IBLOCK_ID"];
}
}
}
// get measures, ratio, sku props data and available quantity
if (!empty($arBasketItems) && $bUseCatalog)
{
$arBasketItems = getMeasures($arBasketItems);
$arBasketItems = getRatio($arBasketItems);
$arBasketItems = $this->getAvailableQuantity($arBasketItems);
}
// 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["PROPS"] = array();
$dbProp = CSaleBasket::GetPropsList(
array("SORT" => "ASC", "ID" => "ASC"),
array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID"))
);
while ($arProp = $dbProp->GetNext())
$arItem["PROPS"][] = $arProp;
//.........这里部分代码省略.........
示例13: fGetFormatedProduct
function fGetFormatedProduct($USER_ID, $LID, $arData, $CNT, $currency, $type, $crmMode = false)
{
$result = "";
if (!is_array($arData) || count($arData) <= 0) {
return $result;
}
$result = "<table width=\"100%\">";
if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock')) {
$arProductId = array();
$arDataTab = array();
$arSkuParentChildren = array();
$arSkuParentId = array();
$arSkuParent = array();
foreach ($arData as $items) {
if ($items["MODULE"] == 'catalog') {
$arProductId[] = $items["PRODUCT_ID"];
$arDataTab[$items["PRODUCT_ID"]] = $items;
$arParent = CCatalogSku::GetProductInfo($items["PRODUCT_ID"]);
if ($arParent) {
$arSkuParentChildren[$items["PRODUCT_ID"]] = $arParent["ID"];
$arSkuParentId[$arParent["ID"]] = $arParent["ID"];
}
}
}
if (!empty($arSkuParentId)) {
$res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
while ($arItems = $res->GetNext()) {
$arSkuParent[$arItems["ID"]] = $arItems;
}
}
if (!empty($arProductId)) {
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
while ($arProduct = $dbProduct->GetNext()) {
$imgCode = "";
$arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
$arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
$arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
$arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
$arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
$arProduct = $arDataTab[$arProduct['ID']];
if ($arProduct["PREVIEW_PICTURE"] == "" && $arProduct["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$arProduct["PRODUCT_ID"]])) {
$idTmp = $arSkuParentChildren[$arProduct["PRODUCT_ID"]];
$arProduct["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
$arProduct["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
}
if ($arProduct["IBLOCK_ID"] > 0) {
$arProduct["EDIT_PAGE_URL"] = "/bitrix/admin/iblock_element_edit.php?ID=" . $arProduct["PRODUCT_ID"] . "&type=" . $arProduct["IBLOCK_TYPE_ID"] . "&lang=" . LANG . "&IBLOCK_ID=" . $arProduct["IBLOCK_ID"] . "&find_section_section=" . intval($arProduct["IBLOCK_SECTION_ID"]);
}
if ($arProduct["DETAIL_PICTURE"] > 0) {
$imgCode = $arProduct["DETAIL_PICTURE"];
} elseif ($arProduct["PREVIEW_PICTURE"] > 0) {
$imgCode = $arProduct["PREVIEW_PICTURE"];
}
$arProduct["NAME"] = htmlspecialcharsex($arProduct["NAME"]);
$arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsex($arProduct["DETAIL_PAGE_URL"]);
$arProduct["CURRENCY"] = htmlspecialcharsex($arProduct["CURRENCY"]);
if ($imgCode > 0) {
$arFile = CFile::GetFileArray($imgCode);
$arImgProduct = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
if (is_array($arImgProduct)) {
$imgUrl = $arImgProduct["src"];
$imgProduct = "<a href=\"" . $arProduct["EDIT_PAGE_URL"] . "\" target=\"_blank\"><img src=\"" . $arImgProduct["src"] . "\" alt=\"\" title=\"" . $arProduct["NAME"] . "\" ></a>";
}
} else {
$imgProduct = "<div class='no_foto'>" . GetMessage('SOD_NO_FOTO') . "</div>";
}
$result .= "<tr>\n\t\t\t\t\t\t\t\t<td class=\"tab_img\">" . $imgProduct . "</td>\n\t\t\t\t\t\t\t\t<td class=\"tab_text\">\n\t\t\t\t\t\t\t\t\t<div class=\"order_name\"><a href=\"" . $arProduct["EDIT_PAGE_URL"] . "\" target=\"_blank\" title=\"" . $arProduct["NAME"] . "\">" . $arProduct["NAME"] . "</a></div>\n\t\t\t\t\t\t\t\t\t<div class=\"order_price\">\n\t\t\t\t\t\t\t\t\t\t" . GetMessage('SOD_ORDER_RECOM_PRICE') . ": <b>" . SaleFormatCurrency($arProduct["PRICE"], $currency) . "</b>\n\t\t\t\t\t\t\t\t\t</div>";
$arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $arProduct["PRODUCT_ID"], $arProduct["NAME"]);
$arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD" => GetMEssage('SOD_POPUP_TO_BUSKET'), "PRODUCT_NOT_ADD" => GetMEssage('SOD_POPUP_TO_BUSKET_NOT'), "PRODUCT_PRICE_FROM" => GetMessage('SOD_POPUP_FROM'));
if (!$crmMode) {
if (count($arResult["SKU_ELEMENTS"]) > 0) {
$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", '', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . " );\"><span></span>" . GetMessage('SOD_SUBTAB_ADD_ORDER') . "</a>";
} else {
$cntProd = floatval($arProduct["QUANTITY"]) > 0 ? floatval($arProduct["QUANTITY"]) : 1;
$url = "/bitrix/admin/sale_order_new.php?lang=" . LANG . "&user_id=" . $USER_ID . "&LID=" . $LID . "&product[" . $arProduct["PRODUCT_ID"] . "]=" . $cntProd;
$result .= "<a href=\"" . $url . "\" target=\"_blank\" class=\"get_new_order\"><span></span>" . GetMessage('SOD_SUBTAB_ADD_ORDER') . "</a>";
}
}
$result .= "</td></tr>";
}
}
}
//end if
$result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
if ($CNT > 2) {
$result .= "<a href='javascript:void(0);' onClick=\"fGetMoreProduct('" . $type . "');\" class=\"get_more\">" . GetMessage('SOD_SUBTAB_MORE') . "<span></span></a>";
}
$result .= "</td></tr>";
$result .= "</table>";
return $result;
}
示例14: basket_items
//.........这里部分代码省略.........
$arResult["VAT_SUM"] += roundEx($arItem["VAT_VALUE"] * $arItem["QUANTITY"], SALE_VALUE_PRECISION);
}
$arItem["PRICE_FORMATED"] = SaleFormatCurrency($arItem["PRICE"], $arItem["CURRENCY"]);
$arItem["WEIGHT_FORMATED"] = roundEx(DoubleVal($arItem["WEIGHT"]/$arResult["WEIGHT_KOEF"]), SALE_WEIGHT_PRECISION)." ".$arResult["WEIGHT_UNIT"];
if($arItem["DISCOUNT_PRICE"] > 0)
{
$arItem["DISCOUNT_PRICE_PERCENT"] = $arItem["DISCOUNT_PRICE"]*100 / ($arItem["DISCOUNT_PRICE"] + $arItem["PRICE"]);
$arItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arItem["DISCOUNT_PRICE_PERCENT"], 0)."%";
}
$arItem["PROPS"] = Array();
$dbProp = CSaleBasket::GetPropsList(Array("SORT" => "ASC", "ID" => "ASC"), Array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
while($arProp = $dbProp -> GetNext())
{
if (array_key_exists('BASKET_ID', $arProp))
{
unset($arProp['BASKET_ID']);
}
if (array_key_exists('~BASKET_ID', $arProp))
{
unset($arProp['~BASKET_ID']);
}
$arProp = array_filter($arProp, array("CSaleBasketHelper", "filterFields"));
$arItem["PROPS"][] = $arProp;
}
if (!CSaleBasketHelper::isSetItem($arItem))
{
$DISCOUNT_PRICE_ALL += $arItem["DISCOUNT_PRICE"] * $arItem["QUANTITY"];
$arItem["DISCOUNT_PRICE"] = roundEx($arItem["DISCOUNT_PRICE"], SALE_VALUE_PRECISION);
$arResult["ORDER_PRICE"] += $arItem["PRICE"] * $arItem["QUANTITY"];
}
$arResult["ORDER_WEIGHT"] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
if (CSaleBasketHelper::isSetItem($arItem))
$arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem['QUANTITY'];
//get product section
$db_groups = CIBlockElement::GetElementGroups($arItem["PRODUCT_ID"], true);
while($ar_group = $db_groups->Fetch())
$arItem["IBLOCK_SECTION_ID"][] = $ar_group["ID"];
if(!$arItem["IBLOCK_SECTION_ID"]){
$arItem["PARENT"] = CCatalogSku::GetProductInfo(
$arItem["PRODUCT_ID"]
);
$db_groups = CIBlockElement::GetElementGroups($arItem["PARENT"]["ID"], true);
while($ar_group = $db_groups->Fetch())
$arItem["IBLOCK_SECTION_ID"][] = $ar_group["ID"];
}
if($arItem["IBLOCK_SECTION_ID"]){
foreach($arItem["IBLOCK_SECTION_ID"] as $section){
$res_1 = CIBlockSection::GetByID($section);
if($ar_res_1 = $res_1->GetNext()){
$arItem["SECTION_NAME"][] = $ar_res_1["NAME"];
}
}
}
$arResult["BASKET_ITEMS"][] = $arItem;
}
$arResult["PRICE_WITHOUT_DISCOUNT"] = SaleFormatCurrency($arResult["ORDER_PRICE"] + $DISCOUNT_PRICE_ALL, $allCurrency);
// count weight for set parent products
foreach ($arResult["BASKET_ITEMS"] as &$arItem)
{
if (CSaleBasketHelper::isSetParent($arItem))
{
$arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
$arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $arResult["WEIGHT_KOEF"]), SALE_WEIGHT_PRECISION)." ".$arResult["WEIGHT_UNIT"];
}
}
$arResult["ORDER_WEIGHT_FORMATED"] = roundEx(DoubleVal($arResult["ORDER_WEIGHT"]/$arResult["WEIGHT_KOEF"]), SALE_WEIGHT_PRECISION)." ".$arResult["WEIGHT_UNIT"];
$arResult["ORDER_PRICE_FORMATED"] = SaleFormatCurrency($arResult["ORDER_PRICE"], $arResult["BASE_LANG_CURRENCY"]);
$arResult["VAT_SUM_FORMATED"] = SaleFormatCurrency($arResult["VAT_SUM"], $arResult["BASE_LANG_CURRENCY"]);
$arElementId[] = $arItem["PRODUCT_ID"];
if ($bUseCatalog)
{
$arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
if ($arParent)
{
$arElementId[] = $arParent["ID"];
$arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"];
}
}
unset($arItem);
}
return $arResult["BASKET_ITEMS"];
}
示例15: array
$viewedMessage = "";
} else {
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $PRODUCT_ID), false, false, array('ID', 'NAME', "XML_ID", "IBLOCK_EXTERNAL_ID"));
$arProduct = $dbProduct->Fetch();
$arViews['NAME'] = $arProduct["NAME"];
$arViews['PRODUCT_ID'] = $arProduct["ID"];
$arViews['MODULE'] = "catalog";
$arViews["LID"] = $LID;
}
} else {
$dbViewsList = CSaleViewedProduct::GetList(array(), array("FUSER_ID" => $arFuserItems["ID"], "PRODUCT_ID" => $PRODUCT_ID), false, false);
$arViews = $dbViewsList->Fetch();
}
if (strlen($viewedError) <= 0) {
$arFields = array("PROPS" => array());
$arParentSku = CCatalogSku::GetProductInfo($PRODUCT_ID);
if ($arParentSku && count($arParentSku) > 0) {
$arPropsSku = array();
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $PRODUCT_ID), false, false, array('IBLOCK_ID'));
$arProduct = $dbProduct->Fetch();
$dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
while ($arOfferProperties = $dbOfferProperties->Fetch()) {
$arPropsSku[] = $arOfferProperties["CODE"];
}
$arFields["PROPS"] = CIBlockPriceTools::GetOfferProperties($PRODUCT_ID, $arParentSku["IBLOCK_ID"], $arPropsSku);
}
$arFields["USER_ID"] = $ID;
$arFields["PRODUCT_ID"] = $PRODUCT_ID;
$arFields["PRICE"] = $arViews["PRICE"];
$arFields["CURRENCY"] = $arViews["CURRENCY"];
$arFields["QUANTITY"] = 1;