Ejemplo n.º 1
1
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
	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;
	}
Ejemplo n.º 4
0
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 
Ejemplo n.º 5
0
    }
}
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"));
Ejemplo n.º 6
0
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"];
			}
		}

		$arElementInfo["MODULE"] = "catalog";
		$arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";

		$arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];

		if ($arElementInfo["IBLOCK_ID"] > 0)
		{
			$arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array(
				"find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"],
				'WF' => 'Y',
			));
		}

		$arBuyerGroups = CUser::GetUserGroup($userId);

		// price
		$arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
		$currentPrice = $arPrice["DISCOUNT_PRICE"];
		$arElementInfo["PRICE"] = $currentPrice;
		$arElementInfo["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
		$arElementInfo["DISCOUNT_PRICE"] = $arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"];
		$currentTotalPrice = ($arElementInfo["PRICE"] + $arElementInfo["DISCOUNT_PRICE"]);
		$discountPercent = 0;
		if ($arElementInfo["DISCOUNT_PRICE"] > 0)
			$discountPercent = intval(($arElementInfo["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);

		$rsProducts = CCatalogProduct::GetList(
			array(),
			array('ID' => $productId),
			false,
			false,
			array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')
		);
		if (!($arProduct = $rsProducts->Fetch()))
		{
			return array();
		}
		$balance = floatval($arProduct["QUANTITY"]);

		// sku props
		$arSkuData = array();
		$arProps[] = array(
			"NAME" => "Catalog XML_ID",
			"CODE" => "CATALOG.XML_ID",
			"VALUE" => $arElementInfo['~IBLOCK_XML_ID']
		);
		$arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
		if (!empty($arSkuProperty))
		{
			foreach ($arSkuProperty as &$val)
			{
				$arSkuData[] = array(
					'NAME' => $val['NAME'],
					'VALUE' => $val['VALUE'],
					'CODE' => $val['CODE']
				);
			}
			unset($val);
		}
		$arSkuData[] = array(
			"NAME" => "Product XML_ID",
			"CODE" => "PRODUCT.XML_ID",
			"VALUE" => $arElementInfo["~XML_ID"]
		);

		// currency
		$arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
		$priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);

		$arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];

		// measure
		$arElementInfo["MEASURE_TEXT"] = "";
		if ((int)$arProduct["MEASURE"] > 0)
		{
			$dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
			if ($arMeasure = $dbMeasure->Fetch())
				$arElementInfo["MEASURE_TEXT"] = ($arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]);
		}
		if ($arElementInfo["MEASURE_TEXT"] == '')
		{
			$arElementInfo["MEASURE_TEXT"] = ($defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]);
		}


		// ratio
		$arElementInfo["RATIO"] = 1;
		$dbratio = CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
		if ($arRatio = $dbratio->Fetch())
			$arElementInfo["RATIO"] = $arRatio["RATIO"];

		// image
		if ($arElementInfo["PREVIEW_PICTURE"] > 0)
			$imgCode = $arElementInfo["PREVIEW_PICTURE"];
		elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
			$imgCode = $arElementInfo["DETAIL_PICTURE"];

		if ($imgCode == "" && count($arParent) > 0)
		{
			if ($arParent["PREVIEW_PICTURE"] > 0)
				$imgCode = $arParent["PREVIEW_PICTURE"];
			elseif ($arParent["DETAIL_PICTURE"] > 0)
				$imgCode = $arParent["DETAIL_PICTURE"];
		}

		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"];
		}

		$arSetInfo = array();
		$arStores = array();

		/** @var $productProvider IBXSaleProductProvider */
		if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
		{
			// get set items if it is set
			if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
			{
				if (method_exists($productProvider, "GetSetItems"))
				{
					$arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);

					if ($tmpId == "")
						$tmpId = randString(7);

					if (!empty($arSets))
					{
						foreach ($arSets as $arSetData)
						{
							foreach ($arSetData["ITEMS"] as $setItem)
							{
								$arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call

								// re-define some fields with set data values
								$arSetItemParams["id"] = $setItem["PRODUCT_ID"];
								$arSetItemParams["name"] = $setItem["NAME"];
								$arSetItemParams["module"] = $setItem["MODULE"];
								$arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
								$arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
								$arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
								$arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
								$arSetItemParams["productType"] = $setItem["TYPE"];
								$arSetItemParams["weight"] = $setItem["WEIGHT"];
								$arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
								$arSetItemParams["setItems"] = "";

								$arSetItemParams["setParentId"] = $productId."_tmp".$tmpId;
								$arSetItemParams["isSetItem"] = "Y";
								$arSetItemParams["isSetParent"] = "N";

								$arSetInfo[] = $arSetItemParams;
							}
						}
					}
				}
			}

			// get stores
			$storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID)); // with exact SITE_ID or SITE_ID = NULL

			if ($storeCount > 0)
			{
				if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID)))
					$arStores = $arProductStore;
			}
		}

		$currentTotalPrice = (float)$currentTotalPrice;
		// params array
		$arParams["id"] = $productId;
		$arParams["name"] = $arElementInfo["~NAME"];
		$arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
		$arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
		$arParams["urlImg"] = $imgUrl;
		$arParams["price"] = floatval($arElementInfo["PRICE"]);
		$arParams["priceBase"] = $currentTotalPrice;
		$arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
		$arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
		$arParams["valutaFormat"] = $priceValutaFormat;
		$arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
		$arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
		$arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
		$arParams["discountPercent"] = $discountPercent;
		$arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
		$arParams["quantity"] = $quantity;
		$arParams["module"] = $arElementInfo["MODULE"];
		$arParams["currency"] = $arElementInfo["CURRENCY"];
		$arParams["weight"] = $arElementInfo["WEIGHT"];
		$arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
		$arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
		$arParams["balance"] = $balance;
		$arParams["notes"] = (is_array($arPrice["PRICE"]) && array_key_exists("CATALOG_GROUP_NAME", $arPrice["PRICE"])) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "";
		$arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
		$arParams["productXmlID"] = $arElementInfo["~XML_ID"];
		$arParams["callback"] = "";
		$arParams["orderCallback"] = "";
		$arParams["cancelCallback"] = "";
		$arParams["payCallback"] = "";
		$arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
		$arParams["skuProps"] = $arSkuData;
		$arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
		$arParams["ratio"] = $arElementInfo["RATIO"];
		$arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];

		$arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
		$arParams["setParentId"] = empty($arSetInfo) ? "" : $productId."_tmp".$tmpId;

		$arParams["setItems"] = $arSetInfo;
		$arParams["isSetItem"] = "N";
		$arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";

		$arParams["stores"] = empty($arSetInfo) ? $arStores : array();
		$arParams["productPropsValues"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps)
	}

	return $arParams;
}
Ejemplo n.º 7
0
             }
         }
         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;
Ejemplo n.º 8
0
$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"]);
Ejemplo n.º 9
0
					}

					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"));
Ejemplo n.º 10
0
 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) {
             $arImage = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]);
             if ($arImage) {
                 $arFileTmp = CFile::ResizeImageGet($arImage, array("width" => "110", "height" => "110"), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                 $arItem["PREVIEW_PICTURE_SRC"] = $arFileTmp["src"];
             }
         }
         $arItem["DETAIL_PICTURE_SRC"] = "";
         if (isset($arItem["DETAIL_PICTURE"]) && intval($arItem["DETAIL_PICTURE"]) > 0) {
             $arImage = CFile::GetFileArray($arItem["DETAIL_PICTURE"]);
             if ($arImage) {
                 $arFileTmp = CFile::ResizeImageGet($arImage, array("width" => "110", "height" => "110"), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                 $arItem["DETAIL_PICTURE_SRC"] = $arFileTmp["src"];
             }
         }
     }
     unset($arItem);
     // get sku props data
     if (!empty($arBasketItems) && $bUseCatalog && isset($this->offersProps) && !empty($this->offersProps)) {
         $arBasketItems = $this->getSkuPropsData($arBasketItems, $arParents, $this->offersProps);
     }
     // count weight for set parent products
     foreach ($arBasketItems as &$arItem) {
         if (CSaleBasketHelper::isSetParent($arItem)) {
             $arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
             $arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
         }
     }
     if (isset($arItem)) {
         unset($arItem);
     }
     // fill item arrays for old templates
     foreach ($arBasketItems as &$arItem) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         if ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "N") {
             $allSum += $arItem["PRICE"] * $arItem["QUANTITY"];
             $allWeight += $arItem["WEIGHT"] * $arItem["QUANTITY"];
             $allVATSum += roundEx($arItem["PRICE_VAT_VALUE"] * $arItem["QUANTITY"], SALE_VALUE_PRECISION);
             $bShowReady = True;
             if (doubleval($arItem["DISCOUNT_PRICE"]) > 0) {
                 if (0 < doubleval($arItem["DISCOUNT_PRICE"] + $arItem["PRICE"])) {
                     $arItem["DISCOUNT_PRICE_PERCENT"] = $arItem["DISCOUNT_PRICE"] * 100 / ($arItem["DISCOUNT_PRICE"] + $arItem["PRICE"]);
                 } else {
                     $arItem["DISCOUNT_PRICE_PERCENT"] = 0;
                 }
                 $arItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arItem["DISCOUNT_PRICE_PERCENT"], SALE_VALUE_PRECISION) . "%";
                 $DISCOUNT_PRICE_ALL += $arItem["DISCOUNT_PRICE"] * $arItem["QUANTITY"];
             }
             $arResult["ITEMS"]["AnDelCanBuy"][] = $arItem;
         } elseif ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "Y") {
             $bShowDelay = True;
             $arResult["ITEMS"]["DelDelCanBuy"][] = $arItem;
         } elseif ($arItem["CAN_BUY"] == "N" && $arItem["SUBSCRIBE"] == "Y") {
             $bShowSubscribe = True;
             $arResult["ITEMS"]["ProdSubscribe"][] = $arItem;
         } else {
             $bShowNotAvail = True;
             $arItem["NOT_AVAILABLE"] = true;
             $arResult["ITEMS"]["nAnCanBuy"][] = $arItem;
         }
     }
     unset($arItem);
     $arResult["ShowReady"] = $bShowReady ? "Y" : "N";
     $arResult["ShowDelay"] = $bShowDelay ? "Y" : "N";
     $arResult["ShowNotAvail"] = $bShowNotAvail ? "Y" : "N";
     $arResult["ShowSubscribe"] = $bShowSubscribe ? "Y" : "N";
     $arOrder = array('SITE_ID' => $this->getSiteId(), 'USER_ID' => $this->userId, 'ORDER_PRICE' => $allSum, 'ORDER_WEIGHT' => $allWeight, 'BASKET_ITEMS' => $arResult["ITEMS"]["AnDelCanBuy"]);
     $arOptions = array('COUNT_DISCOUNT_4_ALL_QUANTITY' => $this->countDiscount4AllQuantity);
     $arErrors = array();
     CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
     $allSum = 0;
     $allWeight = 0;
     $allVATSum = 0;
     $DISCOUNT_PRICE_ALL = 0;
     $priceWithoutDiscount = 0;
     foreach ($arOrder["BASKET_ITEMS"] as &$arOneItem) {
         $allWeight += $arOneItem["WEIGHT"] * $arOneItem["QUANTITY"];
         $allSum += $arOneItem["PRICE"] * $arOneItem["QUANTITY"];
         if (array_key_exists('VAT_VALUE', $arOneItem)) {
             $arOneItem["PRICE_VAT_VALUE"] = $arOneItem["VAT_VALUE"];
         }
         $allVATSum += roundEx($arOneItem["PRICE_VAT_VALUE"] * $arOneItem["QUANTITY"], SALE_VALUE_PRECISION);
         $arOneItem["PRICE_FORMATED"] = $this->getSaleFormatCurrency($arOneItem["PRICE"], $arOneItem["CURRENCY"]);
         $arOneItem["FULL_PRICE"] = $arOneItem["PRICE"] + $arOneItem["DISCOUNT_PRICE"];
         $arOneItem["FULL_PRICE_FORMATED"] = $this->getSaleFormatCurrency($arOneItem["FULL_PRICE"], $arOneItem["CURRENCY"]);
         $arOneItem["SUM"] = $this->getSaleFormatCurrency($arOneItem["PRICE"] * $arOneItem["QUANTITY"], $arOneItem["CURRENCY"]);
         if (0 < doubleval($arOneItem["DISCOUNT_PRICE"] + $arOneItem["PRICE"])) {
             $arOneItem["DISCOUNT_PRICE_PERCENT"] = $arOneItem["DISCOUNT_PRICE"] * 100 / ($arOneItem["DISCOUNT_PRICE"] + $arOneItem["PRICE"]);
         } else {
             $arOneItem["DISCOUNT_PRICE_PERCENT"] = 0;
         }
         $arOneItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arOneItem["DISCOUNT_PRICE_PERCENT"], SALE_VALUE_PRECISION) . "%";
         $DISCOUNT_PRICE_ALL += $arOneItem["DISCOUNT_PRICE"] * $arOneItem["QUANTITY"];
     }
     unset($arOneItem);
     $arResult["ITEMS"]["AnDelCanBuy"] = $arOrder["BASKET_ITEMS"];
     // fill grid data (for new templates with custom columns)
     foreach ($arResult["ITEMS"] as $type => $arItems) {
         foreach ($arItems as $k => $arItem) {
             $arResult["GRID"]["ROWS"][$arItem["ID"]] = $arItem;
         }
     }
     $arResult["allSum"] = $allSum;
     $arResult["allWeight"] = $allWeight;
     $arResult["allWeight_FORMATED"] = roundEx(doubleval($allWeight / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
     $arResult["allSum_FORMATED"] = $this->getSaleFormatCurrency($allSum, $allCurrency);
     $arResult["DISCOUNT_PRICE_FORMATED"] = $this->getSaleFormatCurrency($arResult["DISCOUNT_PRICE"], $allCurrency);
     $arResult["PRICE_WITHOUT_DISCOUNT"] = $this->getSaleFormatCurrency($allSum + $DISCOUNT_PRICE_ALL, $allCurrency);
     if ($this->priceVatShowValue == 'Y') {
         $arResult["allVATSum"] = $allVATSum;
         $arResult["allVATSum_FORMATED"] = $this->getSaleFormatCurrency($allVATSum, $allCurrency);
         $arResult["allSum_wVAT_FORMATED"] = $this->getSaleFormatCurrency(doubleval($arResult["allSum"] - $allVATSum), $allCurrency);
     }
     if (!empty($arCoupons)) {
         $arResult["COUPON"] = htmlspecialcharsbx($arCoupons[0]);
     }
     if (count($arBasketItems) <= 0) {
         $arResult["ERROR_MESSAGE"] = GetMessage("SALE_EMPTY_BASKET");
     }
     $arResult["DISCOUNT_PRICE_ALL"] = $DISCOUNT_PRICE_ALL;
     $arResult["DISCOUNT_PRICE_ALL_FORMATED"] = $this->getSaleFormatCurrency($DISCOUNT_PRICE_ALL, $allCurrency);
     return $arResult;
 }
Ejemplo n.º 11
0
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;
}
Ejemplo n.º 12
0
	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;

			$arItem["PRICE_VAT_VALUE"] = (($arItem["PRICE"] / ($arItem["VAT_RATE"] +1)) * $arItem["VAT_RATE"]);
			$arItem["PRICE_FORMATED"] = SaleFormatCurrency($arItem["PRICE"], $arItem["CURRENCY"]);

			$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 (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)) // if sku element doesn't have value of some property - we'll show parent element value instead
			{
				$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]))) // can be array or string
					{
						$arItem[$fieldVal] = $arProductData[$parentId][$fieldVal];
					}
				}
			}

			foreach ($arItem as $key => $value) // format properties' values
			{
				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)
			{
				$arImage = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]);
				if ($arImage)
				{
					$arFileTmp = CFile::ResizeImageGet(
						$arImage,
						array("width" => "110", "height" =>"110"),
						BX_RESIZE_IMAGE_PROPORTIONAL,
						true
					);

					$arItem["PREVIEW_PICTURE_SRC"] = $arFileTmp["src"];
				}
			}

			$arItem["DETAIL_PICTURE_SRC"] = "";
			if (isset($arItem["DETAIL_PICTURE"]) && intval($arItem["DETAIL_PICTURE"]) > 0)
			{
				$arImage = CFile::GetFileArray($arItem["DETAIL_PICTURE"]);
				if ($arImage)
				{
					$arFileTmp = CFile::ResizeImageGet(
						$arImage,
						array("width" => "110", "height" =>"110"),
						BX_RESIZE_IMAGE_PROPORTIONAL,
						true
					);

					$arItem["DETAIL_PICTURE_SRC"] = $arFileTmp["src"];
				}
			}
		}
		unset($arItem);

		// get sku props data
		if (!empty($arBasketItems) && $bUseCatalog && isset($this->offersProps) && !empty($this->offersProps))
		{
			$arBasketItems = $this->getSkuPropsData($arBasketItems, $arParents, $this->offersProps);
		}

		// count weight for set parent products
		foreach ($arBasketItems as &$arItem)
		{
			if (CSaleBasketHelper::isSetParent($arItem))
			{
				$arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
				$arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION)." ".$this->weightUnit;
			}
		}

		if (isset($arItem))
		{
			unset($arItem);
		}
		// fill item arrays for old templates
		foreach ($arBasketItems as &$arItem)
		{
			if (CSaleBasketHelper::isSetItem($arItem))
				continue;

			if ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "N")
			{
				$allSum += ($arItem["PRICE"] * $arItem["QUANTITY"]);
				$allWeight += ($arItem["WEIGHT"] * $arItem["QUANTITY"]);
				$allVATSum += roundEx($arItem["PRICE_VAT_VALUE"] * $arItem["QUANTITY"], SALE_VALUE_PRECISION);

				$bShowReady = True;
				if(doubleval($arItem["DISCOUNT_PRICE"]) > 0)
				{
					if (0 < doubleval($arItem["DISCOUNT_PRICE"] + $arItem["PRICE"]))
					{
						$arItem["DISCOUNT_PRICE_PERCENT"] = $arItem["DISCOUNT_PRICE"]*100 / ($arItem["DISCOUNT_PRICE"] + $arItem["PRICE"]);
					}
					else
					{
						$arItem["DISCOUNT_PRICE_PERCENT"] = 0;
					}
					$arItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arItem["DISCOUNT_PRICE_PERCENT"], SALE_VALUE_PRECISION)."%";
					$DISCOUNT_PRICE_ALL += $arItem["DISCOUNT_PRICE"] * $arItem["QUANTITY"];
				}

				$arResult["ITEMS"]["AnDelCanBuy"][] = $arItem;
			}
			elseif ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "Y")
			{
				$bShowDelay = True;

				$arResult["ITEMS"]["DelDelCanBuy"][] = $arItem;
			}
			elseif ($arItem["CAN_BUY"] == "N" && $arItem["SUBSCRIBE"] == "Y")
			{
				$bShowSubscribe = True;

				$arResult["ITEMS"]["ProdSubscribe"][] = $arItem;
			}
			else
			{
				$bShowNotAvail = True;
				$arItem["NOT_AVAILABLE"] = true;

				$arResult["ITEMS"]["nAnCanBuy"][] = $arItem;
			}
		}
		unset($arItem);

		$arResult["ShowReady"] = (($bShowReady)?"Y":"N");
		$arResult["ShowDelay"] = (($bShowDelay)?"Y":"N");
		$arResult["ShowNotAvail"] = (($bShowNotAvail)?"Y":"N");
		$arResult["ShowSubscribe"] = (($bShowSubscribe)?"Y":"N");

		$arOrder = array(
			'SITE_ID' => SITE_ID,
			'USER_ID' => $GLOBALS["USER"]->GetID(),
			'ORDER_PRICE' => $allSum,
			'ORDER_WEIGHT' => $allWeight,
			'BASKET_ITEMS' => $arResult["ITEMS"]["AnDelCanBuy"]
		);

		$arOptions = array(
			'COUNT_DISCOUNT_4_ALL_QUANTITY' => $this->countDiscount4AllQuantity,
		);

		$arErrors = array();

		CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);

		$allSum = 0;
		$allWeight = 0;
		$allVATSum = 0;

		$DISCOUNT_PRICE_ALL = 0;
		$priceWithoutDiscount = 0;

		foreach ($arOrder["BASKET_ITEMS"] as &$arOneItem)
		{
			$allWeight += ($arOneItem["WEIGHT"] * $arOneItem["QUANTITY"]);
			$allSum += ($arOneItem["PRICE"] * $arOneItem["QUANTITY"]);

			if (array_key_exists('VAT_VALUE', $arOneItem))
				$arOneItem["PRICE_VAT_VALUE"] = $arOneItem["VAT_VALUE"];
			$allVATSum += roundEx($arOneItem["PRICE_VAT_VALUE"] * $arOneItem["QUANTITY"], SALE_VALUE_PRECISION);
			$arOneItem["PRICE_FORMATED"] = SaleFormatCurrency($arOneItem["PRICE"], $arOneItem["CURRENCY"]);

			$arOneItem["FULL_PRICE"] = $arOneItem["PRICE"] + $arOneItem["DISCOUNT_PRICE"];
			$arOneItem["FULL_PRICE_FORMATED"] = SaleFormatCurrency($arOneItem["FULL_PRICE"], $arOneItem["CURRENCY"]);

			$arOneItem["SUM"] = SaleFormatCurrency($arOneItem["PRICE"] * $arOneItem["QUANTITY"], $arOneItem["CURRENCY"]);

			if (0 < doubleval($arOneItem["DISCOUNT_PRICE"] + $arOneItem["PRICE"]))
			{
				$arOneItem["DISCOUNT_PRICE_PERCENT"] = $arOneItem["DISCOUNT_PRICE"]*100 / ($arOneItem["DISCOUNT_PRICE"] + $arOneItem["PRICE"]);
			}
			else
			{
				$arOneItem["DISCOUNT_PRICE_PERCENT"] = 0;
			}
			$arOneItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arOneItem["DISCOUNT_PRICE_PERCENT"], SALE_VALUE_PRECISION)."%";
			$DISCOUNT_PRICE_ALL += $arOneItem["DISCOUNT_PRICE"] * $arOneItem["QUANTITY"];
		}
		unset($arOneItem);

		$arResult["ITEMS"]["AnDelCanBuy"] = $arOrder["BASKET_ITEMS"];

		// fill grid data (for new templates with custom columns)
		foreach ($arResult["ITEMS"] as $type => $arItems)
		{
			foreach ($arItems as $k => $arItem)
			{
				$arResult["GRID"]["ROWS"][$arItem["ID"]] = $arItem;
			}
		}

		$arResult["allSum"] = $allSum;
		$arResult["allWeight"] = $allWeight;
		$arResult["allWeight_FORMATED"] = roundEx(doubleval($allWeight/$this->weightKoef), SALE_WEIGHT_PRECISION)." ".$this->weightUnit;
		$arResult["allSum_FORMATED"] = SaleFormatCurrency($allSum, $allCurrency);
		$arResult["DISCOUNT_PRICE_FORMATED"] = SaleFormatCurrency($arResult["DISCOUNT_PRICE"], $allCurrency);
		$arResult["PRICE_WITHOUT_DISCOUNT"] = SaleFormatCurrency($allSum + $DISCOUNT_PRICE_ALL, $allCurrency);

		if ($this->priceVatShowValue == 'Y')
		{
			$arResult["allVATSum"] = $allVATSum;
			$arResult["allVATSum_FORMATED"] = SaleFormatCurrency($allVATSum, $allCurrency);
			$arResult["allSum_wVAT_FORMATED"] = SaleFormatCurrency(doubleval($arResult["allSum"]-$allVATSum), $allCurrency);
		}

		if ($this->hideCoupon != "Y")
			$arCoupons = CCatalogDiscountCoupon::GetCoupons();

		if (!empty($arCoupons))
			$arResult["COUPON"] = htmlspecialcharsbx($arCoupons[0]);
		if(count($arBasketItems)<=0)
			$arResult["ERROR_MESSAGE"] = GetMessage("SALE_EMPTY_BASKET");

		$arResult["DISCOUNT_PRICE_ALL"] = $DISCOUNT_PRICE_ALL;
		$arResult["DISCOUNT_PRICE_ALL_FORMATED"] = SaleFormatCurrency($DISCOUNT_PRICE_ALL, $allCurrency);

		if($this->usePrepayment == "Y")
		{
			if(doubleval($arResult["allSum"]) > 0)
			{
				$personType = array();
				$dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => SITE_ID, "ACTIVE" => "Y"));
				while($arPersonType = $dbPersonType->Fetch())
				{
					$personType[] = $arPersonType["ID"];
				}

				if(!empty($personType))
				{
					$dbPaySysAction = CSalePaySystemAction::GetList(
							array(),
							array(
									"PS_ACTIVE" => "Y",
									"HAVE_PREPAY" => "Y",
									"PERSON_TYPE_ID" => $personType,
								),
							false,
							false,
							array("ID", "PAY_SYSTEM_ID", "PERSON_TYPE_ID", "NAME", "ACTION_FILE", "RESULT_FILE", "NEW_WINDOW", "PARAMS", "ENCODING", "LOGOTIP")
						);
					if ($arPaySysAction = $dbPaySysAction->Fetch())
					{
						CSalePaySystemAction::InitParamarrays(false, false, $arPaySysAction["PARAMS"]);

						$pathToAction = $_SERVER["DOCUMENT_ROOT"].$arPaySysAction["ACTION_FILE"];

						$pathToAction = str_replace("\\", "/", $pathToAction);
						while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/")
							$pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1);

						if (file_exists($pathToAction))
						{
							if (is_dir($pathToAction) && file_exists($pathToAction."/pre_payment.php"))
								$pathToAction .= "/pre_payment.php";

							include_once($pathToAction);
							$psPreAction = new CSalePaySystemPrePayment;

							if($psPreAction->init())
							{
								$orderData = array(
										"PATH_TO_ORDER" => $this->pathToOrder,
										"AMOUNT" => $arResult["allSum"],
										"BASKET_ITEMS" => $arResult["ITEMS"]["AnDelCanBuy"],
									);
								if(!$psPreAction->BasketButtonAction($orderData))
								{
									if($e = $APPLICATION->GetException())
										$arResult["WARNING_MESSAGE"][] = $e->GetString();
								}

								$arResult["PREPAY_BUTTON"] = $psPreAction->BasketButtonShow();
							}
						}
					}
				}
			}
		}

		return $arResult;
	}
Ejemplo n.º 13
0
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
    global $crmMode;
    $result = "";
    if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 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["ITEMS"] as $items) {
            if ($items["MODULE"] == "catalog") {
                $arProductId[$items["PRODUCT_ID"]] = $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"];
                }
            }
        }
        $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;
        }
        $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->Fetch()) {
            $imgCode = 0;
            $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'];
            $items = $arDataTab[$arProduct['ID']];
            if ($items["PREVIEW_PICTURE"] == "" && $items["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$items["PRODUCT_ID"]])) {
                $idTmp = $arSkuParentChildren[$items["PRODUCT_ID"]];
                $items["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
                $items["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
            }
            if ($items["DETAIL_PICTURE"] > 0) {
                $imgCode = $items["DETAIL_PICTURE"];
            } elseif ($items["PREVIEW_PICTURE"] > 0) {
                $imgCode = $items["PREVIEW_PICTURE"];
            }
            $arSkuProperty = CSaleProduct::GetProductSkuProps($items["PRODUCT_ID"]);
            $items["NAME"] = htmlspecialcharsex($items["NAME"]);
            $items["EDIT_PAGE_URL"] = htmlspecialcharsex($items["EDIT_PAGE_URL"]);
            $items["CURRENCY"] = htmlspecialcharsex($items["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=\"" . $items["EDIT_PAGE_URL"] . "\" target=\"_blank\"><img src=\"" . $imgUrl . "\" alt=\"\" title=\"" . $items["NAME"] . "\" ></a>";
            } else {
                $imgProduct = "<div class='no_foto'>" . GetMessage('NO_FOTO') . "</div>";
            }
            $arCurFormat = CCurrencyLang::GetCurrencyFormat($items["CURRENCY"]);
            $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
            $currentTotalPrice = $items["PRICE"] + $items["DISCOUNT_PRICE"];
            $discountPercent = 0;
            if ($items["DISCOUNT_PRICE"] > 0) {
                $discountPercent = IntVal($items["DISCOUNT_PRICE"] * 100 / $currentTotalPrice);
            }
            $ar_res = CCatalogProduct::GetByID($items["PRODUCT_ID"]);
            $balance = FloatVal($ar_res["QUANTITY"]);
            $arParams = array();
            $arParams["id"] = $items["PRODUCT_ID"];
            $arParams["name"] = $items["NAME"];
            $arParams["url"] = $items["DETAIL_PAGE_URL"];
            $arParams["urlEdit"] = $items["EDIT_PAGE_URL"];
            $arParams["urlImg"] = $imgUrl;
            $arParams["price"] = FloatVal($items["PRICE"]);
            $arParams["priceBase"] = FloatVal($currentTotalPrice);
            $arParams["priceBaseFormat"] = CurrencyFormatNumber(FloatVal($currentTotalPrice), $items["CURRENCY"]);
            $arParams["priceFormated"] = CurrencyFormatNumber(FloatVal($items["PRICE"]), $items["CURRENCY"]);
            $arParams["valutaFormat"] = $priceValutaFormat;
            $arParams["priceDiscount"] = FloatVal($items["DISCOUNT_PRICE"]);
            $arParams["priceTotalFormated"] = SaleFormatCurrency($currentTotalPrice, $items["CURRENCY"]);
            $arParams["discountPercent"] = $discountPercent;
            $arParams["summaFormated"] = CurrencyFormatNumber($items["PRICE"], $items["CURRENCY"]);
            $arParams["quantity"] = 1;
            $arParams["module"] = $items["MODULE"];
            $arParams["currency"] = $items["CURRENCY"];
            $arParams["weight"] = 0;
            $arParams["vatRate"] = 0;
            $arParams["priceType"] = "";
            $arParams["balance"] = $balance;
            $arParams['skuProps'] = CUtil::PhpToJSObject($arSkuProperty);
            $arParams["catalogXmlID"] = "";
            $arParams["productXmlID"] = "";
            $arParams["callback"] = "CatalogBasketCallback";
            $arParams["orderCallback"] = "CatalogBasketOrderCallback";
            $arParams["cancelCallback"] = "CatalogBasketCancelCallback";
            $arParams["payCallback"] = "CatalogPayOrderCallback";
            $result .= "<tr id='more_" . $type . "_" . $items["ID"] . "'>\n\t\t\t\t\t\t\t<td class=\"tab_img\" >" . $imgProduct . "</td>\n\t\t\t\t\t\t\t<td class=\"tab_text\">\n\t\t\t\t\t\t\t\t<div class=\"order_name\"><a href=\"" . $items["EDIT_PAGE_URL"] . "\" target=\"_blank\" title=\"" . $items["NAME"] . "\">" . $items["NAME"] . "</a></div>\n\t\t\t\t\t\t\t\t<div class=\"order_price\">\n\t\t\t\t\t\t\t\t\t" . GetMessage('NEWO_SUBTAB_PRICE') . ": <b>" . SaleFormatCurrency($items["PRICE"], $currency) . "</b>\n\t\t\t\t\t\t\t\t</div>";
            $arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $items["PRODUCT_ID"], $items["NAME"]);
            if (count($arResult["SKU_ELEMENTS"]) > 0) {
                foreach ($arResult["SKU_ELEMENTS"] as $key => $val) {
                    $arTmp = array();
                    foreach ($val as $k => $v) {
                        if (is_numeric($k)) {
                            $arTmp[$arResult["SKU_PROPERTIES"][$k]["NAME"]] = $v;
                        }
                    }
                    $arResult["SKU_ELEMENTS"][$key]["SKU_PROPS"] = CUtil::PhpToJSObject($arTmp);
                }
            }
            $arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD" => GetMEssage('NEWO_POPUP_TO_BUSKET'), "PRODUCT_ORDER" => GetMEssage('NEWO_POPUP_TO_ORDER'), "PRODUCT_NOT_ADD" => GetMEssage('NEWO_POPUP_DONT_CAN_BUY'), "PRODUCT_PRICE_FROM" => GetMessage('NEWO_POPUP_FROM'));
            if (count($arResult["SKU_ELEMENTS"]) <= 0) {
                $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProduct('" . $type . "', " . CUtil::PhpToJSObject($arParams) . ");return false;\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_BUSKET') . "</a><br>";
            } else {
                $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'busket', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_BUSKET') . "</a><br>";
            }
            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']) . ", 'neworder', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_ORDER') . "</a>";
                } else {
                    $cntProd = floatval($items["QUANTITY"]) > 0 ? floatval($items["QUANTITY"]) : 1;
                    $url = "/bitrix/admin/sale_order_new.php?lang=" . LANG . "&user_id=" . $USER_ID . "&LID=" . $LID . "&product[" . $items["PRODUCT_ID"] . "]=" . $cntProd;
                    $result .= "<a href=\"" . $url . "\" target=\"_blank\" class=\"get_new_order\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_ORDER') . "</a>";
                }
            }
            $result .= "</td></tr>";
        }
        //end foreach
    }
    //end if
    if ($arData["CNT"] > 2 && $arData["CNT"] != count($arData["ITEMS"])) {
        $result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
        if ($type == "busket") {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreBusket(\"Y\");' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        } elseif ($type == "viewed") {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreViewed(\"Y\");' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        } else {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreRecom();' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        }
        $result .= "</td></tr>";
    }
    $result .= "</table>";
    return $result;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
    private function basket_items() {
        CModule::IncludeModule("iblock");
        CModule::IncludeModule("sale");
        
        CSaleBasket::UpdateBasketPrices(CSaleBasket::GetBasketUserID(), SITE_ID);
		/* Check Values Begin */

		$arSelFields = array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY",
			"CAN_BUY", "PRICE", "WEIGHT", "NAME", "CURRENCY", "CATALOG_XML_ID", "VAT_RATE",
			"NOTES", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "DIMENSIONS", "TYPE", "SET_PARENT_ID", "DETAIL_PAGE_URL"
		);
		$dbBasketItems = CSaleBasket::GetList(
				array("ID" => "ASC"),
				array(
						"FUSER_ID" => CSaleBasket::GetBasketUserID(),
						"LID" => SITE_ID,
						"ORDER_ID" => "NULL"
					),
				false,
				false,
				$arSelFields
			);
		while ($arItem = $dbBasketItems->GetNext())
		{
			if ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y")
			{
				$arItem["PRICE"] = roundEx($arItem["PRICE"], SALE_VALUE_PRECISION);
				$arItem["QUANTITY"] = DoubleVal($arItem["QUANTITY"]);

				$arItem["WEIGHT"] = DoubleVal($arItem["WEIGHT"]);
				$arItem["VAT_RATE"] = DoubleVal($arItem["VAT_RATE"]);

				$arDim = unserialize($arItem["~DIMENSIONS"]);

				if(is_array($arDim))
				{
					$arItem["DIMENSIONS"] = $arDim;
					unset($arItem["~DIMENSIONS"]);

					$arResult["MAX_DIMENSIONS"] = CSaleDeliveryHelper::getMaxDimensions(
                        array(
					       $arDim["WIDTH"],
					       $arDim["HEIGHT"],
					       $arDim["LENGTH"]
					    ),
		            $arResult["MAX_DIMENSIONS"]);

					$arResult["ITEMS_DIMENSIONS"][] = $arDim;
				}

				if($arItem["VAT_RATE"] > 0 && !CSaleBasketHelper::isSetItem($arItem))
				{
					$arResult["bUsingVat"] = "Y";
					if($arItem["VAT_RATE"] > $arResult["VAT_RATE"])
						$arResult["VAT_RATE"] = $arItem["VAT_RATE"];
					//$arItem["VAT_VALUE"] = roundEx((($arItem["PRICE"] / ($arItem["VAT_RATE"] +1)) * $arItem["VAT_RATE"]), SALE_VALUE_PRECISION);
					$arItem["VAT_VALUE"] = (($arItem["PRICE"] / ($arItem["VAT_RATE"] +1)) * $arItem["VAT_RATE"]);

					$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"];
    }
Ejemplo n.º 16
0
         $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;
Ejemplo n.º 17
0
 /**
  * @override
  * @return integer[]
  */
 protected function getProductIds()
 {
     if (!$this->arParams['ID']) {
         return array();
     }
     $info = CCatalogSku::GetProductInfo($this->arParams['ID']);
     $ids = array();
     if ($info) {
         $ids = $this->getRecommendedIds($this->arParams['ID'], $this->arParams['OFFERS_PROPERTY_LINK']);
         if (!count($ids)) {
             $ids = $this->getRecommendedIds($info['ID'], $this->arParams['PROPERTY_LINK']);
         }
     } else {
         $ids = $this->getRecommendedIds($this->arParams['ID'], $this->arParams['PROPERTY_LINK']);
     }
     return $ids;
 }
Ejemplo n.º 18
0
	public static function GetSetItems($productID, $intType, $arProducInfo = array())
	{
		$arProductId = array();
		$arSets = CCatalogProductSet::getAllSetsByProduct($productID, $intType);

		if (is_array($arSets))
		{
			foreach ($arSets as $k => $arSet)
			{
				foreach ($arSet["ITEMS"] as $k1 => $item)
				{
					$arItem = self::GetProductData(array("PRODUCT_ID" => $item["ITEM_ID"], "QUANTITY" => $item["QUANTITY"], "CHECK_QUANTITY" => "N", "CHECK_PRICE" => "N"));

					$arItem["PRODUCT_ID"] = $item["ITEM_ID"];
					$arItem["MODULE"] = "catalog";
					$arItem["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
					if ($intType == CCatalogProductSet::TYPE_SET)
					{
						$arItem['SET_DISCOUNT_PERCENT'] = ($item['DISCOUNT_PERCENT'] == '' ? false : (float)$item['DISCOUNT_PERCENT']);
					}

					$arProductId[] = $item["ITEM_ID"];

					$arItem["PROPS"] = array();
					$arParentSku = CCatalogSku::GetProductInfo($item["ITEM_ID"]);
					if (!empty($arParentSku))
					{
						$arPropsSku = array();

						$dbProduct = CIBlockElement::GetList(array(), array("ID" => $item["ITEM_ID"]), 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(
							$item["ITEM_ID"],
							$arParentSku["IBLOCK_ID"],
							$arPropsSku
						);

						foreach ($product_properties as $propData)
						{
							$arItem["PROPS"][] = array(
								"NAME" => $propData["NAME"],
								"CODE" => $propData["CODE"],
								"VALUE" => $propData["VALUE"],
								"SORT" => $propData["SORT"]
							);
						}
					}

					$arSets[$k]["ITEMS"][$k1] = array_merge($item, $arItem);
				}
			}

			$rsProducts = CIBlockElement::GetList(
				array(),
				array('ID' => $arProductId),
				false,
				false,
				array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "IBLOCK_TYPE_ID", "XML_ID")
			);
			while ($arProduct = $rsProducts->GetNext())
			{
				foreach ($arSets as $k => $arSet)
				{
					foreach ($arSet["ITEMS"] as $k1 => $item)
					{
						if ($item["ITEM_ID"] == $arProduct["ID"])
						{
							$arProps = array();
							$strIBlockXmlID = strval(CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID'));
							if ($strIBlockXmlID != "")
							{
								$arProps[] = array(
									"NAME" => "Catalog XML_ID",
									"CODE" => "CATALOG.XML_ID",
									"VALUE" => $strIBlockXmlID
								);
							}

							$arProps[] = array(
								"NAME" => "Product XML_ID",
								"CODE" => "PRODUCT.XML_ID",
								"VALUE" => $arProduct["XML_ID"]
							);

							$arSets["$k"]["ITEMS"][$k1]["IBLOCK_ID"] = $arProduct["IBLOCK_ID"];
							$arSets["$k"]["ITEMS"][$k1]["IBLOCK_SECTION_ID"] = $arProduct["IBLOCK_SECTION_ID"];
							$arSets["$k"]["ITEMS"][$k1]["PREVIEW_PICTURE"] = $arProduct["PREVIEW_PICTURE"];
							$arSets["$k"]["ITEMS"][$k1]["DETAIL_PICTURE"] = $arProduct["DETAIL_PICTURE"];
							$arSets["$k"]["ITEMS"][$k1]["PROPS"] = array_merge($arSets["$k"]["ITEMS"][$k1]["PROPS"], $arProps);
						}
					}
				}
			}
		}

		foreach(GetModuleEvents("sale", "OnGetSetItems", true) as $arEvent)
			ExecuteModuleEventEx($arEvent, array(&$arSets));

		return $arSets;
	}
Ejemplo n.º 19
0
/**
 * @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)) {
            $arFields = array_merge($arFields, $arRewriteFields);
        }
    }
    $mxBasketID = CSaleBasket::Add($arFields);
    if ($mxBasketID) {
        if (!isset($_SESSION['NOTIFY_PRODUCT'])) {
            $_SESSION['NOTIFY_PRODUCT'] = array($intUserID = array());
        } elseif (!isset($_SESSION['NOTIFY_PRODUCT'][$intUserID])) {
            $_SESSION['NOTIFY_PRODUCT'][$intUserID] = array();
        }
        $_SESSION["NOTIFY_PRODUCT"][$intUserID][$intProductID] = $intProductID;
        if (Loader::includeModule("statistic")) {
            CStatistic::Set_Event("sale2basket", "subscribe", $intProductID);
        }
    }
    return $mxBasketID;
}
Ejemplo n.º 20
0
 private function getProducts()
 {
     if (!($arFilter = $this->getUserFilter())) {
         return array();
     }
     if ($this->arParams['SHOW_NOTAVAIL'] == 'N') {
         $arFilter['CAN_BUY'] = 'Y';
     }
     if ($this->arParams['SHOW_DELAY'] == 'N') {
         $arFilter['DELAY'] = 'N';
     }
     if ($this->arParams['SHOW_SUBSCRIBE'] == 'N') {
         $arFilter["SUBSCRIBE"] = 'N';
     }
     $dbItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), $arFilter, false, false, array("ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "DETAIL_PAGE_URL", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID", "MEASURE_NAME", "PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"));
     $arBasketItems = array();
     $arElementId = array();
     $arSku2Parent = array();
     while ($arItem = $dbItems->GetNext(true, false)) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arItem["PRICE_FMT"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"], $arItem["CURRENCY"], true);
         $arItem["FULL_PRICE"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"] + $arItem["DISCOUNT_PRICE"], $arItem["CURRENCY"], true);
         $arItem['QUANTITY'] += 0;
         // remove excessive zeros after period
         if (!$arItem['MEASURE_NAME']) {
             $arItem['MEASURE_NAME'] = GetMessage('TSB1_MEASURE_NAME');
         }
         if ($this->arParams['SHOW_IMAGE'] == 'Y' && $this->bUseCatalog && $arItem["MODULE"] == 'catalog') {
             $arElementId[] = $arItem["PRODUCT_ID"];
             $arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
             if ($arParent) {
                 $arElementId[] = $arParent["ID"];
                 $arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"];
             }
         }
         $arBasketItems[] = $arItem;
     }
     $arResult = array('CATEGORIES' => array(), 'TOTAL_PRICE' => 0);
     if ($arBasketItems) {
         if ($this->arParams['SHOW_IMAGE'] == 'Y') {
             $this->setImgSrc($arBasketItems, $arElementId, $arSku2Parent);
         }
         $arResult["CATEGORIES"] = array("READY" => array(), "DELAY" => array(), "SUBSCRIBE" => array(), "NOTAVAIL" => array());
         // fill item arrays for templates
         foreach ($arBasketItems as $arItem) {
             if ($arItem["CAN_BUY"] == "Y") {
                 if ($arItem["DELAY"] == "Y") {
                     $arResult["CATEGORIES"]["DELAY"][] = $arItem;
                 } else {
                     $arResult["CATEGORIES"]["READY"][] = $arItem;
                 }
             } else {
                 if ($arItem["SUBSCRIBE"] == "Y") {
                     $arResult["CATEGORIES"]["SUBSCRIBE"][] = $arItem;
                 } else {
                     $arResult["CATEGORIES"]["NOTAVAIL"][] = $arItem;
                 }
             }
         }
         if ($this->arParams['SHOW_PRICE'] == 'Y' || $this->arParams['SHOW_SUMMARY'] == 'Y' || $this->arParams['SHOW_TOTAL_PRICE'] == 'Y') {
             $arOrder = $this->calculateOrder($arResult["CATEGORIES"]["READY"]);
             $arResult["CATEGORIES"]["READY"] = $arOrder['BASKET_ITEMS'];
             foreach ($arResult["CATEGORIES"]["READY"] as &$arItem) {
                 $arItem["SUM"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"] * $arItem["QUANTITY"], $arItem["CURRENCY"], true);
                 $arItem["PRICE_FMT"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"], $arItem["CURRENCY"], true);
             }
             $arResult["TOTAL_PRICE"] = $arOrder['ORDER_PRICE'];
         }
     }
     return array('NUM_PRODUCTS' => count($arBasketItems), 'TOTAL_PRICE' => $arResult["TOTAL_PRICE"], 'CATEGORIES' => $arResult["CATEGORIES"]);
 }
Ejemplo n.º 21
0
<?php

CModule::includeModule('catalog');
CModule::includeModule('iblock');
CModule::includeModule('sale');
$dbBasketItems = CSaleBasket::GetList(array(), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "DELAY" => 'Y', "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "PRODUCT_ID"));
while ($arItems = $dbBasketItems->Fetch()) {
    $mxResult = CCatalogSku::GetProductInfo($arItems['PRODUCT_ID']);
    if (is_array($mxResult)) {
        $id = $mxResult['ID'];
    } else {
        $id = $arItems['PRODUCT_ID'];
    }
    $GLOBALS['wished']['ID'][] = $id;
}
Ejemplo n.º 22
0
<?php

CModule::IncludeModule("sale");
CModule::IncludeModule("iblock");
$arID = array();
$arBasketItems = array();
$dbBasketItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "PRODUCT_ID"));
while ($arItems = $dbBasketItems->Fetch()) {
    $arProducts[] = $arItems['PRODUCT_ID'];
}
foreach ($arProducts as $key => $prod) {
    $mxResult = CCatalogSku::GetProductInfo($prod);
    if (is_array($mxResult)) {
        $arProducts[$key] = $mxResult['ID'];
    }
}
$arFilter = array("ID" => $arProducts);
$arAccessories = array();
$sections_id = array();
$res = CIBlockElement::GetList(array(), $arFilter, false, false, array("ID", 'IBLOCK_ID', 'NAME', 'IBLOCK_SECTION_ID', 'PROPERTY_ACCESSORIES'));
while ($ar_fields = $res->GetNext()) {
    $arAccessories[] = $ar_fields['PROPERTY_ACCESSORIES_VALUE'];
    if (!in_array($ar_fields['IBLOCK_SECTION_ID'], $sections_id)) {
        $sections_id[] = $ar_fields['IBLOCK_SECTION_ID'];
    }
}
$arSecProducts = array();
if (count($sections_id) > 0) {
    $arFilter1 = array('SECTION_ID' => $sections_id);
    $obj = CIBlockElement::GetList(array(), $arFilter1, false, false, array('ID'));
    while ($res1 = $obj->GetNext()) {
Ejemplo n.º 23
0
 public static function GetSetItems($productID, $intType, $arProducInfo = array())
 {
     $arProductId = array();
     static $proxyCatalogProductSet = array();
     static $proxyCatalogSkuData = array();
     static $proxyCatalogProduct = array();
     static $proxyIblockProperty = array();
     static $proxyProductProperty = array();
     $proxyCatalogProductSetKey = $productID . "|" . $intType;
     if (!empty($proxyCatalogProductSet[$proxyCatalogProductSetKey]) && is_array($proxyCatalogProductSet[$proxyCatalogProductSetKey])) {
         $arSets = $proxyCatalogProductSet[$proxyCatalogProductSetKey];
     } else {
         $arSets = CCatalogProductSet::getAllSetsByProduct($productID, $intType);
         if (!empty($arSets) && is_array($arSets)) {
             $proxyCatalogProductSet[$proxyCatalogProductSetKey] = $arSets;
         }
     }
     if (is_array($arSets)) {
         foreach ($arSets as $k => $arSet) {
             foreach ($arSet["ITEMS"] as $k1 => $item) {
                 $arItem = self::GetProductData(array("PRODUCT_ID" => $item["ITEM_ID"], "QUANTITY" => $item["QUANTITY"], "CHECK_QUANTITY" => "N", "CHECK_PRICE" => "N"));
                 if (array_key_exists('QUANTITY_TRACE', $arItem)) {
                     unset($arItem['QUANTITY_TRACE']);
                 }
                 $arItem["PRODUCT_ID"] = $item["ITEM_ID"];
                 $arItem["MODULE"] = "catalog";
                 $arItem["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                 if ($intType == CCatalogProductSet::TYPE_SET) {
                     $arItem['SET_DISCOUNT_PERCENT'] = $item['DISCOUNT_PERCENT'] == '' ? false : (double) $item['DISCOUNT_PERCENT'];
                 }
                 $arProductId[] = $item["ITEM_ID"];
                 $arItem["PROPS"] = array();
                 if (!empty($proxyCatalogSkuData[$item["ITEM_ID"]]) && is_array($proxyCatalogSkuData[$item["ITEM_ID"]])) {
                     $arParentSku = $proxyCatalogSkuData[$item["ITEM_ID"]];
                 } else {
                     if ($arParentSku = CCatalogSku::GetProductInfo($item["ITEM_ID"])) {
                         $proxyCatalogSkuData[$item["ITEM_ID"]] = $arParentSku;
                     }
                 }
                 if (!empty($arParentSku)) {
                     $arPropsSku = array();
                     if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT', $item["ITEM_ID"]))) {
                         $dbProduct = CIBlockElement::GetList(array(), array("ID" => $item["ITEM_ID"]), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'IBLOCK_SECTION_ID'));
                         if ($arProduct = $dbProduct->Fetch()) {
                             static::setHitCache('IBLOCK_ELEMENT', $item["ITEM_ID"], $arProduct);
                         }
                     }
                     if (!($arPropsSku = static::getHitCache('IBLOCK_PROPERTY', $arProduct["IBLOCK_ID"]))) {
                         $dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
                         while ($arOfferProperties = $dbOfferProperties->Fetch()) {
                             $arPropsSku[] = $arOfferProperties["CODE"];
                         }
                         static::setHitCache('IBLOCK_PROPERTY', $arProduct["IBLOCK_ID"], $arPropsSku);
                     }
                     $proxyProductPropertyKey = $item["ITEM_ID"] . "_" . $arParentSku["IBLOCK_ID"] . "_" . md5(join('|', $arPropsSku));
                     if (!($product_properties = static::getHitCache('PRODUCT_PROPERTY', $proxyProductPropertyKey))) {
                         $product_properties = CIBlockPriceTools::GetOfferProperties($item["ITEM_ID"], $arParentSku["IBLOCK_ID"], $arPropsSku);
                         static::setHitCache('PRODUCT_PROPERTY', $proxyProductPropertyKey, $product_properties);
                     }
                     foreach ($product_properties as $propData) {
                         $arItem["PROPS"][] = array("NAME" => $propData["NAME"], "CODE" => $propData["CODE"], "VALUE" => $propData["VALUE"], "SORT" => $propData["SORT"]);
                     }
                 }
                 $arSets[$k]["ITEMS"][$k1] = array_merge($item, $arItem);
             }
         }
         if (!($productList = static::getHitCache('IBLOCK_ELEMENT_LIST', $productID))) {
             $rsProducts = CIBlockElement::GetList(array(), array('ID' => $arProductId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "IBLOCK_TYPE_ID", "XML_ID"));
             while ($arProduct = $rsProducts->GetNext()) {
                 $productList[] = $arProduct;
             }
             if (!empty($productList) && is_array($productList)) {
                 static::setHitCache('IBLOCK_ELEMENT_LIST', $productID, $productList);
             }
         }
         if (!empty($productList) && is_array($productList)) {
             foreach ($productList as $arProduct) {
                 foreach ($arSets as $k => $arSet) {
                     foreach ($arSet["ITEMS"] as $k1 => $item) {
                         if ($item["ITEM_ID"] == $arProduct["ID"]) {
                             $arProps = array();
                             $strIBlockXmlID = strval(CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID'));
                             if ($strIBlockXmlID != "") {
                                 $arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $strIBlockXmlID);
                             }
                             $arProps[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arProduct["XML_ID"]);
                             $arSets["{$k}"]["ITEMS"][$k1]["IBLOCK_ID"] = $arProduct["IBLOCK_ID"];
                             $arSets["{$k}"]["ITEMS"][$k1]["IBLOCK_SECTION_ID"] = $arProduct["IBLOCK_SECTION_ID"];
                             $arSets["{$k}"]["ITEMS"][$k1]["PREVIEW_PICTURE"] = $arProduct["PREVIEW_PICTURE"];
                             $arSets["{$k}"]["ITEMS"][$k1]["DETAIL_PICTURE"] = $arProduct["DETAIL_PICTURE"];
                             $arSets["{$k}"]["ITEMS"][$k1]["PROPS"] = array_merge($arSets["{$k}"]["ITEMS"][$k1]["PROPS"], $arProps);
                         }
                     }
                 }
             }
         }
     }
     foreach (GetModuleEvents("sale", "OnGetSetItems", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$arSets));
     }
     return $arSets;
 }
Ejemplo n.º 24
0
<?php

$quantity = $arResult["GRID"]["HEADERS"][5];
$price = $arResult["GRID"]["HEADERS"][4];
$arResult["GRID"]["HEADERS"][4] = $quantity;
$arResult["GRID"]["HEADERS"][5] = $price;
unset($arResult["GRID"]["HEADERS"][7]);
unset($arResult["GRID"]["HEADERS"][8]);
foreach ($arResult["GRID"]["ROWS"] as $k => $arItem) {
    if (CModule::IncludeModule('iblock')) {
        $bres = CCatalogSku::GetProductInfo($arItem['PRODUCT_ID']);
        if ($bres['ID'] > 0) {
            $idToSearch = $bres['ID'];
        } else {
            $idToSearch = $arItem['PRODUCT_ID'];
        }
        $arResult["GRID"]["ROWS"][$k]['realid'] = $idToSearch;
        $res = CIBlockElement::GetByID($idToSearch);
        $tovar = $res->GetNext();
        $arResult["GRID"]["ROWS"][$k]['DETAIL_PAGE_URL'] = $tovar['DETAIL_PAGE_URL'];
    }
    if ($arItem["PREVIEW_PICTURE"]) {
        $arFileTmp = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"], array("width" => 134, "height" => 100), BX_RESIZE_IMAGE_PROPORTIONAL, true);
        $marginl = (134 - $arFileTmp['width']) / 2;
        $margint = (100 - $arFileTmp['height']) / 2;
        $arResult["GRID"]["ROWS"][$k]['small_pict'] = array("SMALL_SRC" => $arFileTmp["src"], "SMALL_MARGIN_LEFT" => $marginl);
    }
}
Ejemplo n.º 25
0
				"QUANTITY", "NAME", "MODULE", "CALLBACK_FUNC", "NOTES", "DETAIL_PAGE_URL", "DISCOUNT_PRICE",
				"DISCOUNT_VALUE", "ORDER_CALLBACK_FUNC", "CANCEL_CALLBACK_FUNC", "PAY_CALLBACK_FUNC", "CATALOG_XML_ID",
				"PRODUCT_XML_ID", "VAT_RATE", "DISCOUNT_NAME", "DISCOUNT_COUPON", "PRODUCT_PROVIDER_CLASS", "CUSTOM_PRICE",
				"TYPE", "SET_PARENT_ID", "DIMENSIONS", "RECOMMENDATION"
			)
		);
		while ($arBasketTmp = $dbBasketTmp->GetNext())
		{
			$arBasketId[] = $arBasketTmp["ID"];
			$arBasketTmp["DIMENSIONS"] = unserialize($arBasketTmp["~DIMENSIONS"]);

			$arBasketItems[] = $arBasketTmp;

			if (CModule::IncludeModule("catalog"))
			{
				$arParent = CCatalogSku::GetProductInfo($arBasketTmp["PRODUCT_ID"]);
				if ($arParent)
				{
					$arElementId[] = $arParent["ID"];
					$arSku2Parent[$arBasketTmp["PRODUCT_ID"]] = $arParent["ID"];
				}
			}

			$arElementId[] = $arBasketTmp["PRODUCT_ID"];
			$arBasketPropsValues[$arBasketTmp["PRODUCT_ID"]] = array();

			if (!CSaleBasketHelper::isSetItem($arBasketTmp))
				$orderTotalPrice += ($arBasketTmp["PRICE"] + $arBasketTmp["DISCOUNT_PRICE"]) * $arBasketTmp["QUANTITY"];

				if (!CSaleBasketHelper::isSetParent($arBasketTmp))
				{
Ejemplo n.º 26
0
 echo "window.onload = function () {";
 echo "fUserGetProfile(BX(\"user_id\"));\n";
 if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock') && isset($_GET["product"]) && count($_GET["product"]) > 0) {
     $bXmlId = COption::GetOptionString("sale", "show_order_product_xml_id", "N");
     $arProductId = array();
     $arBuyerGroups = CUser::GetUserGroup($str_USER_ID);
     $arGetProduct = array();
     $arSkuParentChildren = array();
     $arSkuParentId = array();
     $arSkuParent = array();
     foreach ($_GET["product"] as $key => $val) {
         $key = IntVal($key);
         if ($key > 0) {
             $arProductId[] = $key;
             $arGetProduct[$key] = floatval($val) > 0 ? floatval($val) : 1;
             $arParent = CCatalogSku::GetProductInfo($key);
             if ($arParent) {
                 $arSkuParentChildren[$key] = $arParent["ID"];
                 $arSkuParentId[$arParent["ID"]] = $arParent["ID"];
             }
         }
     }
     $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;
     }
     $arOrder["SORT"] = "ASC";
     if (count($arGetProduct) > 0) {
         $res = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
         while ($arItems = $res->GetNext()) {
             $productImg = "";
Ejemplo n.º 27
0
			$arProductImg = array();
			$hidden = "";
			$setItemClass = "";
			if (CSaleBasketHelper::isSetItem($val))
			{
				$hidden = "style=\"display:none\"";
				$setItemClass = "class=\"set_item_".$val["SET_PARENT_ID"]."\"";
			}

			if ($bUseIblock)
			{
				$arProductImg["PREVIEW_PICTURE"] = $arProductData[$val["PRODUCT_ID"]]["PREVIEW_PICTURE"];
				$arProductImg["DETAIL_PICTURE"] = $arProductData[$val["PRODUCT_ID"]]["DETAIL_PICTURE"];

				if ($bUseCatalog)
					$arParent = CCatalogSku::GetProductInfo($val["PRODUCT_ID"]);
				if ($arParent)
				{
					if (empty($arProductImg["PREVIEW_PICTURE"]))
						$arProductImg["PREVIEW_PICTURE"] = $arProductData[$arParent["ID"]]["PREVIEW_PICTURE"];

					if (empty($arProductImg["DETAIL_PICTURE"]))
						$arProductImg["DETAIL_PICTURE"] = $arProductData[$arParent["ID"]]["DETAIL_PICTURE"];
				}

				if($arProductImg["PREVIEW_PICTURE"] != "")
					$productImg = $arProductImg["PREVIEW_PICTURE"];
				elseif($arProductImg["DETAIL_PICTURE"] != "")
					$productImg = $arProductImg["DETAIL_PICTURE"];
			}
Ejemplo n.º 28
0
 function CalculateAffiliate($affiliate, $dateFrom = false, $dateTo = false, $datePlanFrom = false, $datePlanTo = false)
 {
     global $DB;
     // Prepare function params - affiliate
     $arAffiliate = CSaleAffiliate::CheckAffiliateFunc($affiliate);
     if (!$arAffiliate) {
         return False;
     }
     $db_events = GetModuleEvents("sale", "OnBeforeAffiliateCalculate");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$arAffiliate, &$dateFrom, &$dateTo, &$datePlanFrom, &$datePlanTo)) === false) {
             return false;
         }
     }
     $affiliateID = IntVal($arAffiliate["ID"]);
     if (!$dateFrom || StrLen($dateFrom) <= 0) {
         if (StrLen($arAffiliate["LAST_CALCULATE"]) > 0) {
             $dateFrom = $arAffiliate["LAST_CALCULATE"];
         } else {
             $dateFrom = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), mktime(0, 0, 0, 1, 1, 1990));
         }
     }
     if (!$dateTo || StrLen($dateTo) <= 0) {
         $dateTo = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time() + CTimeZone::GetOffset());
     }
     // Get affiliate plan
     $arAffiliatePlan = CSaleAffiliate::SetAffiliatePlan($arAffiliate, $datePlanFrom, $datePlanTo);
     if (!$arAffiliatePlan) {
         return False;
     }
     if ($arAffiliatePlan && !is_array($arAffiliatePlan)) {
         return true;
     }
     // Get affiliate plan params
     $arPlanSections = array();
     $dbPlanSection = CSaleAffiliatePlanSection::GetList(array(), array("PLAN_ID" => $arAffiliate["PLAN_ID"]), false, false, array("ID", "MODULE_ID", "SECTION_ID", "RATE", "RATE_TYPE", "RATE_CURRENCY"));
     while ($arPlanSection = $dbPlanSection->Fetch()) {
         $arPlanSections[$arPlanSection["MODULE_ID"] . $arPlanSection["SECTION_ID"]] = $arPlanSection;
     }
     // Get affiliate parents
     $arAffiliateParents = array();
     $affiliateParent = IntVal($arAffiliate["AFFILIATE_ID"]);
     $count = 0;
     while ($affiliateParent > 0 && $count < 5) {
         $dbAffiliateParent = CSaleAffiliate::GetList(array(), array("ID" => $affiliateParent, "ACTIVE" => "Y"), false, false, array("ID", "AFFILIATE_ID"));
         if ($arAffiliateParent = $dbAffiliateParent->Fetch()) {
             $count++;
             $arAffiliateParents[] = $affiliateParent;
             $affiliateParent = IntVal($arAffiliateParent["AFFILIATE_ID"]);
         } else {
             $affiliateParent = 0;
         }
     }
     // Get tier
     if (!array_key_exists("SALE_AFFILIATE_TIER_TMP_CACHE", $GLOBALS)) {
         $GLOBALS["SALE_AFFILIATE_TIER_TMP_CACHE"] = array();
     }
     if (!array_key_exists($arAffiliate["SITE_ID"], $GLOBALS["SALE_AFFILIATE_TIER_TMP_CACHE"])) {
         $dbAffiliateTier = CSaleAffiliateTier::GetList(array(), array("SITE_ID" => $arAffiliate["SITE_ID"]), false, false, array("RATE1", "RATE2", "RATE3", "RATE4", "RATE5"));
         if ($arAffiliateTier = $dbAffiliateTier->Fetch()) {
             $GLOBALS["SALE_AFFILIATE_TIER_TMP_CACHE"][$arAffiliate["SITE_ID"]] = array(DoubleVal($arAffiliateTier["RATE1"]), DoubleVal($arAffiliateTier["RATE2"]), DoubleVal($arAffiliateTier["RATE3"]), DoubleVal($arAffiliateTier["RATE4"]), DoubleVal($arAffiliateTier["RATE5"]));
         } else {
             $GLOBALS["SALE_AFFILIATE_TIER_TMP_CACHE"][$arAffiliate["SITE_ID"]] = array(0, 0, 0, 0, 0);
         }
     }
     // Orders cicle
     $affiliateSum = 0;
     $affiliateCurrency = CSaleLang::GetLangCurrency($arAffiliate["SITE_ID"]);
     $dbOrders = \Bitrix\Sale\Internals\OrderTable::getList(array('filter' => array("=ALLOW_DELIVERY" => 'Y', ">=DATE_ALLOW_DELIVERY" => $dateFrom, "<DATE_ALLOW_DELIVERY" => $dateTo, "=AFFILIATE_ID" => $affiliateID, "=LID" => $arAffiliate["SITE_ID"], "=CANCELED" => 'N'), 'select' => array("ID", "LID", "PRICE_DELIVERY", "PRICE", "CURRENCY", "TAX_VALUE", "AFFILIATE_ID", "BASKET_QUANTITY" => 'BASKET.QUANTITY', "BASKET_PRODUCT_ID" => 'BASKET.PRODUCT_ID', "BASKET_MODULE" => 'BASKET.MODULE', "BASKET_PRICE" => 'BASKET.PRICE', "BASKET_CURRENCY" => 'BASKET.CURRENCY', "BASKET_DISCOUNT_PRICE" => 'BASKET.DISCOUNT_PRICE'), 'order' => array('ID' => 'ASC')));
     $fOrderId = "";
     while ($arOrder = $dbOrders->fetch()) {
         $arProductSections = array();
         if (!array_key_exists("SALE_PRODUCT_SECTION_CACHE", $GLOBALS)) {
             $GLOBALS["SALE_PRODUCT_SECTION_CACHE"] = array();
         }
         if (array_key_exists($arOrder["BASKET_MODULE"] . $arOrder["BASKET_PRODUCT_ID"], $GLOBALS["SALE_PRODUCT_SECTION_CACHE"])) {
             $arProductSections = $GLOBALS["SALE_PRODUCT_SECTION_CACHE"][$arOrder["BASKET_MODULE"] . $arOrder["BASKET_PRODUCT_ID"]];
             unset($GLOBALS["SALE_PRODUCT_SECTION_CACHE"][$arOrder["BASKET_MODULE"] . $arOrder["BASKET_PRODUCT_ID"]]);
             $GLOBALS["SALE_PRODUCT_SECTION_CACHE"] = $GLOBALS["SALE_PRODUCT_SECTION_CACHE"] + array($arOrder["BASKET_MODULE"] . $arOrder["BASKET_PRODUCT_ID"] => $arProductSections);
         } else {
             if ($arOrder["BASKET_MODULE"] == "catalog") {
                 CModule::IncludeModule("catalog");
                 $arSku = CCatalogSku::GetProductInfo($arOrder["BASKET_PRODUCT_ID"]);
                 if ($arSku && count($arSku) > 0) {
                     $elementId = $arSku["ID"];
                 } else {
                     $elementId = $arOrder["BASKET_PRODUCT_ID"];
                 }
                 $arProductSections = CCatalogProduct::GetProductSections($elementId);
             } else {
                 $events = GetModuleEvents("sale", "OnAffiliateGetSections");
                 if ($arEvent = $events->Fetch()) {
                     $arProductSections = ExecuteModuleEventEx($arEvent, array($arOrder["BASKET_MODULE"], $arOrder["BASKET_PRODUCT_ID"]));
                 }
             }
             $GLOBALS["SALE_PRODUCT_SECTION_CACHE"] = $GLOBALS["SALE_PRODUCT_SECTION_CACHE"] + array($arOrder["BASKET_MODULE"] . $arOrder["BASKET_PRODUCT_ID"] => $arProductSections);
             if (count($GLOBALS["SALE_PRODUCT_SECTION_CACHE"]) > 20) {
                 array_shift($GLOBALS["SALE_PRODUCT_SECTION_CACHE"]);
             }
         }
         $realRate = $arAffiliatePlan["BASE_RATE"];
         $realRateType = $arAffiliatePlan["BASE_RATE_TYPE"];
         $realRateCurrency = $arAffiliatePlan["BASE_RATE_CURRENCY"];
         $coountArProd = count($arProductSections);
         for ($i = 0; $i < $coountArProd; $i++) {
             if (array_key_exists($arOrder["BASKET_MODULE"] . $arProductSections[$i], $arPlanSections)) {
                 $realRate = $arPlanSections[$arOrder["BASKET_MODULE"] . $arProductSections[$i]]["RATE"];
                 $realRateType = $arPlanSections[$arOrder["BASKET_MODULE"] . $arProductSections[$i]]["RATE_TYPE"];
                 $realRateCurrency = $arPlanSections[$arOrder["BASKET_MODULE"] . $arProductSections[$i]]["RATE_CURRENCY"];
                 break;
             }
         }
         if ($realRateType == "P") {
             if ($arOrder["CURRENCY"] != $affiliateCurrency) {
                 if (!array_key_exists("SALE_CONVERT_CURRENCY_CACHE", $GLOBALS)) {
                     $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"] = array();
                 }
                 if (!array_key_exists($arOrder["CURRENCY"] . "-" . $affiliateCurrency, $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"])) {
                     $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"][$arOrder["CURRENCY"] . "-" . $affiliateCurrency] = CCurrencyRates::GetConvertFactor($arOrder["CURRENCY"], $affiliateCurrency);
                 }
                 if ($fOrderId != $arOrder["ID"]) {
                     $affiliateSum += \Bitrix\Sale\PriceMaths::roundPrecision(($arOrder["PRICE"] - $arOrder["PRICE_DELIVERY"]) * $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"][$arOrder["CURRENCY"] . "-" . $affiliateCurrency] * $realRate / 100);
                     $fOrderId = $arOrder["ID"];
                 }
             } else {
                 if ($fOrderId != $arOrder["ID"]) {
                     $affiliateSum += \Bitrix\Sale\PriceMaths::roundPrecision(($arOrder["PRICE"] - $arOrder["PRICE_DELIVERY"]) * $realRate / 100);
                     $fOrderId = $arOrder["ID"];
                 }
             }
         } else {
             if ($realRateCurrency != $affiliateCurrency) {
                 if (!array_key_exists("SALE_CONVERT_CURRENCY_CACHE", $GLOBALS)) {
                     $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"] = array();
                 }
                 if (!array_key_exists($realRateCurrency . "-" . $affiliateCurrency, $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"])) {
                     $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"][$realRateCurrency . "-" . $affiliateCurrency] = CCurrencyRates::GetConvertFactor($realRateCurrency, $affiliateCurrency);
                 }
                 $affiliateSum += roundEx($realRate * $GLOBALS["SALE_CONVERT_CURRENCY_CACHE"][$realRateCurrency . "-" . $affiliateCurrency], SALE_VALUE_PRECISION);
             } else {
                 $affiliateSum += roundEx($realRate, SALE_VALUE_PRECISION);
             }
         }
     }
     $arFields = array("=PENDING_SUM" => "PENDING_SUM + " . $affiliateSum, "LAST_CALCULATE" => $dateTo);
     $res = CSaleAffiliate::Update($affiliateID, $arFields);
     if (!$res) {
         return False;
     }
     if ($affiliateSum > 0) {
         $cnt = min(count($arAffiliateParents), count($GLOBALS["SALE_AFFILIATE_TIER_TMP_CACHE"][$arAffiliate["SITE_ID"]]));
         for ($i = 0; $i < $cnt; $i++) {
             $affiliateSumTmp = roundEx($affiliateSum * $GLOBALS["SALE_AFFILIATE_TIER_TMP_CACHE"][$arAffiliate["SITE_ID"]][$i] / 100, SALE_VALUE_PRECISION);
             $arFields = array("=PENDING_SUM" => "PENDING_SUM + " . $affiliateSumTmp);
             CSaleAffiliate::Update($arAffiliateParents[$i], $arFields);
         }
     }
     $events = GetModuleEvents("sale", "OnAfterAffiliateCalculate");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($affiliateID));
     }
     return True;
 }
Ejemplo n.º 29
0
 /**
  * Function gets order basket info from the database
  * @param mixed[] Cached data taken from obtainDataCachedStructure()
  * @return void
  */
 protected function obtainBasket(&$cached)
 {
     if (empty($this->dbResult["ID"])) {
         return;
     }
     $basket = array();
     $arSetParentWeight = array();
     $dbBasket = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $this->dbResult["ID"]), false, false, array("ID", "DETAIL_PAGE_URL", "NAME", "NOTES", "QUANTITY", "PRICE", "CURRENCY", "PRODUCT_ID", "DISCOUNT_PRICE", "WEIGHT", "CATALOG_XML_ID", "VAT_RATE", "PRODUCT_XML_ID", "TYPE", "SET_PARENT_ID", "MEASURE_CODE", "MEASURE_NAME", "MODULE"));
     while ($arItem = $dbBasket->Fetch()) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         if ($this->useCatalog && $this->cameFromCatalog($arItem)) {
             $arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]);
             if (!empty($arParent)) {
                 $arItem['PARENT'] = $arParent;
             }
         }
         // adjust some sale params
         $arItem["PRICE_VAT_VALUE"] = $arItem["PRICE"] / ($arItem["VAT_RATE"] + 1) * $arItem["VAT_RATE"];
         $arItem["WEIGHT"] = doubleval($arItem["WEIGHT"]);
         // weight manipulation for product that has type "SET" (nabor)
         if (CSaleBasketHelper::isSetItem($arItem)) {
             $arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
         }
         if (CSaleBasketHelper::isSetParent($arItem)) {
             $arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
         }
         $basket[] = $arItem;
     }
     // fetching all properties
     $this->obtainBasketProps($basket);
     $cached["BASKET"] = $basket;
 }
Ejemplo n.º 30
0
 public function GetXMLData($product)
 {
     $arProp = array("ID" => GetMessage("ACRIT_PROP_ID"), "CODE" => GetMessage("ACRIT_PROP_CODE"), "NAME" => GetMessage("ACRIT_PROP_NAME"), "ACTIVE" => GetMessage("ACRIT_PROP_ACTIVE"), "DATE_CREATE" => GetMessage("ACRIT_PROP_DATE_CREATE"), "CREATED_BY" => GetMessage("ACRIT_PROP_CREATED_BY"), "DETAIL_PAGE_URL" => GetMessage("ACRIT_PROP_DETAIL_PAGE_URL"), "SHOW_COUNTER" => GetMessage("ACRIT_PROP_SHOW_COUNTER"), "QUANTITY" => GetMessage("ACRIT_PROP_QUANTITY"));
     $params = array();
     if (is_array($this->XML_DATA) && sizeof($this->XML_DATA) > 0) {
         foreach ($this->XML_DATA as $xml) {
             $tmp1 = explode("-", $xml['ID']);
             $tmp = explode("_", $tmp1[1]);
             if ($tmp[0] == "SKU") {
                 $ibl = $this->sku_IBLOCK_ID[$tmp1[0]];
                 $prop_id = $tmp[1];
                 $ph = CIBlockElement::GetProperty($ibl, $product["ID"], array("sort" => "asc"), array("ID" => $prop_id));
             } elseif ($tmp[0] == "QUANTITY") {
                 if ($this->isCat) {
                     $tr = CCatalogProduct::GetByID($product["ID"]);
                     $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($arProp[$xml["ID"]], true, true, $this->ENCODING), "CODE" => $xml["ID"], "VALUE" => $tr["QUANTITY"]);
                 }
                 $ph = false;
                 continue;
             } elseif ($tmp[0] == "PRICE") {
                 $dbProductPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $product["ID"], "CATALOG_GROUP_ID" => $tmp[1]));
                 $price = 0;
                 $names = '';
                 while ($arProductPrice = $dbProductPrices->Fetch()) {
                     if ($arProductPrice["PRICE"] && ($arProductPrice["PRICE"] < $price || !$price)) {
                         $price = $arProductPrice["PRICE"];
                     }
                     $arDissizeofs = CCatalogDiscount::GetDiscountByProduct($arProductPrice["PRODUCT_ID"], array(), "N", $arProductPrice["CATALOG_GROUP_ID"], $this->LID);
                     foreach ($arDissizeofs as $arDissizeof) {
                         if ($arDissizeof["VALUE_TYPE"] == "P") {
                             $price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"] * $arProductPrice["PRICE"] / 100;
                         } else {
                             $price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"];
                         }
                         if ($price_buf && ($price_buf < $price || !$price)) {
                             $price = $price_buf;
                         }
                     }
                     $names = $arProductPrice["CATALOG_GROUP_NAME"];
                 }
                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($names, true, true, $this->ENCODING), "CODE" => $xml["ID"], "VALUE" => $price);
                 $ph = false;
                 continue;
             } else {
                 $ibl = $tmp1[0];
                 $prop_id = $tmp1[1];
                 $mxResult = CCatalogSku::GetProductInfo($product["ID"]);
                 if (is_array($mxResult)) {
                     $ph = CIBlockElement::GetProperty($ibl, $mxResult["ID"], array("sort" => "asc"), array("ID" => $prop_id));
                 } else {
                     $ph = CIBlockElement::GetProperty($ibl, $product["ID"], array("sort" => "asc"), array("ID" => $prop_id));
                 }
             }
             if (is_object($ph)) {
                 while ($ob = $ph->GetNext()) {
                     switch ($ob["PROPERTY_TYPE"]) {
                         case "S":
                             if ($ob["USER_TYPE"] == "UserID") {
                                 $rsUser = CUser::GetByID($ob["VALUE"]);
                                 $arUser = $rsUser->Fetch();
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($arUser["LAST_NAME"] . " " . $arUser["FIRST_NAME"], true, true, $this->ENCODING));
                             } else {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
                             }
                             break;
                         case "L":
                             $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE_ENUM"], true, true, $this->ENCODING));
                             break;
                         case "E":
                             $res = CIBlockElement::GetByID($ob["VALUE"]);
                             while ($ar_res = $res->GetNext()) {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ar_res["NAME"], true, true, $this->ENCODING));
                             }
                             break;
                         case "G":
                             if ($xml['UNIT'] != "product_type") {
                                 $res = CIBlockSection::GetByID($ob["VALUE"]);
                                 while ($ar_res = $res->GetNext()) {
                                     $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ar_res["NAME"], true, true, $this->ENCODING));
                                 }
                                 break;
                             } else {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
                                 break;
                             }
                         case "F":
                             $db_file = CFile::GetByID($ob["VALUE"]);
                             while ($ar_file = $db_file->Fetch()) {
                                 $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => "http://" . $this->DOMAIN_NAME . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $ar_file["SUBDIR"] . "/" . implode("/", array_map("rawurlencode", explode("/", $ar_file["FILE_NAME"]))));
                             }
                             break;
                         case "N":
                             $params[] = array("PARAM" => $xml["UNIT"], "NAME" => text2xml($ob["NAME"], true, true, $this->ENCODING), "CODE" => $ob["CODE"], "VALUE" => text2xml($ob["VALUE"], true, true, $this->ENCODING));
                             break;
                         default:
                             break;
                     }
                 }
             }
         }
     }
     return $params;
 }