function GetBestSellerList($by = "AMOUNT", $arFilter = array(), $arOrderFilter = array(), $limit = 0) { global $DB; $byQuantity = false; if ($by == "QUANTITY") { $byQuantity = true; } $arJoin = array(); $arWhere = array(); $orderFilter = ""; $i = 1; if (is_array($arFilter) && count($arFilter) > 0) { foreach ($arFilter as $key => $value) { $arJoin[] = "LEFT JOIN b_sale_basket_props p" . $i . " ON (b.ID = p" . $i . ".BASKET_ID)"; $arFilter = CSaleProduct::GetFilterOperation($key, $value); $arWhere[] = " AND p" . $i . ".CODE = '" . $arFilter["field"] . "' AND p" . $i . ".VALUE " . $arFilter["operation"] . " " . $arFilter["value"]; $i++; } } $arFields = array("ID" => array("FIELD_NAME" => "O.ID", "FIELD_TYPE" => "int"), "LID" => array("FIELD_NAME" => "O.LID", "FIELD_TYPE" => "string"), "PERSON_TYPE_ID" => array("FIELD_NAME" => "O.PERSON_TYPE_ID", "FIELD_TYPE" => "int"), "PAYED" => array("FIELD_NAME" => "O.PAYED", "FIELD_TYPE" => "string"), "DATE_PAYED" => array("FIELD_NAME" => "O.DATE_PAYED", "FIELD_TYPE" => "datetime"), "EMP_PAYED_ID" => array("FIELD_NAME" => "O.EMP_PAYED_ID", "FIELD_TYPE" => "int"), "CANCELED" => array("FIELD_NAME" => "O.CANCELED", "FIELD_TYPE" => "string"), "DATE_CANCELED" => array("FIELD_NAME" => "O.DATE_CANCELED", "FIELD_TYPE" => "datetime"), "EMP_CANCELED_ID" => array("FIELD_NAME" => "O.EMP_CANCELED_ID", "FIELD_TYPE" => "int"), "REASON_CANCELED" => array("FIELD_NAME" => "O.REASON_CANCELED", "FIELD_TYPE" => "string"), "STATUS_ID" => array("FIELD_NAME" => "O.STATUS_ID", "FIELD_TYPE" => "string"), "DATE_STATUS" => array("FIELD_NAME" => "O.DATE_STATUS", "FIELD_TYPE" => "datetime"), "PAY_VOUCHER_NUM" => array("FIELD_NAME" => "O.PAY_VOUCHER_NUM", "FIELD_TYPE" => "string"), "PAY_VOUCHER_DATE" => array("FIELD_NAME" => "O.PAY_VOUCHER_DATE", "FIELD_TYPE" => "date"), "EMP_STATUS_ID" => array("FIELD_NAME" => "O.EMP_STATUS_ID", "FIELD_TYPE" => "int"), "PRICE_DELIVERY" => array("FIELD_NAME" => "O.PRICE_DELIVERY", "FIELD_TYPE" => "double"), "ALLOW_DELIVERY" => array("FIELD_NAME" => "O.ALLOW_DELIVERY", "FIELD_TYPE" => "string"), "DATE_ALLOW_DELIVERY" => array("FIELD_NAME" => "O.DATE_ALLOW_DELIVERY", "FIELD_TYPE" => "datetime"), "EMP_ALLOW_DELIVERY_ID" => array("FIELD_NAME" => "O.EMP_ALLOW_DELIVERY_ID", "FIELD_TYPE" => "int"), "PRICE" => array("FIELD_NAME" => "O.PRICE", "FIELD_TYPE" => "double"), "CURRENCY" => array("FIELD_NAME" => "O.CURRENCY", "FIELD_TYPE" => "string"), "DISCOUNT_VALUE" => array("FIELD_NAME" => "O.DISCOUNT_VALUE", "FIELD_TYPE" => "double"), "SUM_PAID" => array("FIELD_NAME" => "O.SUM_PAID", "FIELD_TYPE" => "double"), "USER_ID" => array("FIELD_NAME" => "O.USER_ID", "FIELD_TYPE" => "int"), "PAY_SYSTEM_ID" => array("FIELD_NAME" => "O.PAY_SYSTEM_ID", "FIELD_TYPE" => "int"), "DELIVERY_ID" => array("FIELD_NAME" => "O.DELIVERY_ID", "FIELD_TYPE" => "string"), "DATE_INSERT" => array("FIELD_NAME" => "O.DATE_INSERT", "FIELD_TYPE" => "datetime"), "DATE_INSERT_FORMAT" => array("FIELD_NAME" => "O.DATE_INSERT", "FIELD_TYPE" => "datetime"), "DATE_UPDATE" => array("FIELD_NAME" => "O.DATE_UPDATE", "FIELD_TYPE" => "datetime"), "USER_DESCRIPTION" => array("FIELD_NAME" => "O.USER_DESCRIPTION", "FIELD_TYPE" => "string"), "ADDITIONAL_INFO" => array("FIELD_NAME" => "O.ADDITIONAL_INFO", "FIELD_TYPE" => "string"), "PS_STATUS" => array("FIELD_NAME" => "O.PS_STATUS", "FIELD_TYPE" => "string"), "PS_STATUS_CODE" => array("FIELD_NAME" => "O.PS_STATUS_CODE", "FIELD_TYPE" => "string"), "PS_STATUS_DESCRIPTION" => array("FIELD_NAME" => "O.PS_STATUS_DESCRIPTION", "FIELD_TYPE" => "string"), "PS_STATUS_MESSAGE" => array("FIELD_NAME" => "O.PS_STATUS_MESSAGE", "FIELD_TYPE" => "string"), "PS_SUM" => array("FIELD_NAME" => "O.PS_SUM", "FIELD_TYPE" => "double"), "PS_CURRENCY" => array("FIELD_NAME" => "O.PS_CURRENCY", "FIELD_TYPE" => "string"), "PS_RESPONSE_DATE" => array("FIELD_NAME" => "O.PS_RESPONSE_DATE", "FIELD_TYPE" => "datetime"), "COMMENTS" => array("FIELD_NAME" => "O.COMMENTS", "FIELD_TYPE" => "string"), "TAX_VALUE" => array("FIELD_NAME" => "O.TAX_VALUE", "FIELD_TYPE" => "double"), "STAT_GID" => array("FIELD_NAME" => "O.STAT_GID", "FIELD_TYPE" => "string"), "RECURRING_ID" => array("FIELD_NAME" => "O.RECURRING_ID", "FIELD_TYPE" => "int"), "RECOUNT_FLAG" => array("FIELD_NAME" => "O.RECOUNT_FLAG", "FIELD_TYPE" => "string"), "AFFILIATE_ID" => array("FIELD_NAME" => "O.AFFILIATE_ID", "FIELD_TYPE" => "int"), "DELIVERY_DOC_NUM" => array("FIELD_NAME" => "O.DELIVERY_DOC_NUM", "FIELD_TYPE" => "string"), "DELIVERY_DOC_DATE" => array("FIELD_NAME" => "O.DELIVERY_DOC_DATE", "FIELD_TYPE" => "date")); if (is_array($arOrderFilter) && count($arOrderFilter) > 0) { $sqlWhere = new CSQLWhere(); $sqlWhere->SetFields($arFields, $arJ); $orderFilter = $sqlWhere->GetQueryEx($arOrderFilter, $arJ); } //if($byQuantity) // $strSql = "SELECT b.PRODUCT_ID, b.CATALOG_XML_ID, b.PRODUCT_XML_ID, SUM(b.QUANTITY) as QUANTITY \n"; //else $strSql = "SELECT b.PRODUCT_ID, b.NAME, b.CATALOG_XML_ID, b.PRODUCT_XML_ID, SUM(b.PRICE*b.QUANTITY) as PRICE, AVG(b.PRICE) as AVG_PRICE, SUM(b.QUANTITY) as QUANTITY, b.CURRENCY \n"; $strSql .= "FROM b_sale_basket b \n"; foreach ($arJoin as $v) { $strSql .= $v . "\n"; } if (strlen($orderFilter) > 0) { $strSql .= "INNER JOIN b_sale_order O ON (b.ORDER_ID = O.ID) \n"; } $strSql .= "WHERE \n" . " b.ORDER_ID is not null \n"; foreach ($arWhere as $v) { $strSql .= $v . "\n"; } if (strlen($orderFilter) > 0) { $strSql .= " AND " . $orderFilter . "\n"; } $strSql .= " GROUP BY b.PRODUCT_ID, b.CATALOG_XML_ID, b.PRODUCT_XML_ID, b.CURRENCY \n"; if ($byQuantity) { $strSql .= " ORDER BY QUANTITY DESC\n"; } else { $strSql .= " ORDER BY PRICE DESC\n"; } if (IntVal($limit) > 0) { $strSql .= "LIMIT " . IntVal($limit); } // echo htmlspecialcharsbx($strSql); $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); return $dbRes; }
<input type="hidden" name="recom_more_viewed" id="recom_more_viewed" value="N" > <table width="100%" class="order_summary"> <tr> <td valign="top" id="itog_tabs" class="load_product"> <table width="100%" class="itog_header"><tr><td><?php echo GetMessage('NEWO_SUBTAB_RECOM_REQUEST'); ?> </td></tr></table> <br> <div id="tabs"> <? $displayNone = "block"; $displayNoneBasket = "block"; $displayNoneViewed = "block"; $arRecommended = CSaleProduct::GetRecommendetProduct($str_USER_ID, $LID, $arFilterRecommended); $arRecommendedResult = fDeleteDoubleProduct($arRecommended, $arFilterRecommended, 'N'); if (empty($arRecommendedResult["ITEMS"])) $displayNone = "none"; $arCartWithoutSetItems = array(); $arTmpShoppingCart = CSaleBasket::DoGetUserShoppingCart($LID, $str_USER_ID, $FUSER_ID, $arErrors, $arCoupon); if (is_array($arTmpShoppingCart)) { foreach ($arTmpShoppingCart as $arCartItem) { if (CSaleBasketHelper::isSetItem($arCartItem)) continue;
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; }
<table width="100%" class="order_summary"> <tr> <td class="load_product" valign="top"> <table width="100%" class="itog_header"><tr><td><?php echo GetMessage('SOD_SUBTAB_RECOM_REQUEST'); ?> </td></tr></table> <br> <div id="tabs"> <? $displayNone = "block"; $displayNoneBasket = "block"; $displayNoneViewed = "block"; $arRecommendedResult = CSaleProduct::GetRecommendetProduct($arOrder["USER_ID"], $arOrder["LID"], $arFilterRecomendet); $recomCnt = count($arRecommendedResult); if ($recomCnt > 2) { $arTmp = array(); $arTmp[] = $arRecommendedResult[0]; $arTmp[] = $arRecommendedResult[1]; $arRecommendedResult = $arTmp; } if ($recomCnt <= 0) $displayNone = "none"; $arErrors = array(); $arFuserItems = CSaleUser::GetList(array("USER_ID" => intval($arOrder["USER_ID"])));
/** * @override * @return integer[] */ protected function getProductIds() { $ordersfilter = $this->getOrdersFilter(); if (!empty($ordersfilter)) { $productIds = array(); $productIterator = CSaleProduct::GetBestSellerList($this->arParams["BY"], array(), $ordersfilter, $this->arParams["PAGE_ELEMENT_COUNT"]); while ($product = $productIterator->fetch()) { $productIds[] = $product['PRODUCT_ID']; } return $productIds; } return array(); }
/** * get sku for product. * * @param integer $USER_ID User. * @param string $LID Site. * @param integer $PRODUCT_ID Product id. * @param string $PRODUCT_NAME Product name. * @param string CURRENCY Currency. * @param array $arProduct Iblock list. * @return array|false */ function GetProductSku($USER_ID, $LID, $PRODUCT_ID, $PRODUCT_NAME = '', $CURRENCY = '', $arProduct = array()) { $USER_ID = (int) $USER_ID; $PRODUCT_ID = (int) $PRODUCT_ID; if ($PRODUCT_ID <= 0) { return false; } $LID = trim($LID); if ($LID == '') { return false; } $PRODUCT_NAME = trim($PRODUCT_NAME); $arResult = array(); $arOffers = array(); static $arCacheGroups = array(); if (!is_set($arCacheGroups[$USER_ID])) { $arCacheGroups[$USER_ID] = CUser::GetUserGroup($USER_ID); } $arGroups = $arCacheGroups[$USER_ID]; if (empty($arProduct)) { $arProduct = CSaleProduct::GetProductListIblockInfo(array($PRODUCT_ID)); } static $arOffersIblock = array(); if (!is_set($arOffersIblock[$arProduct["IBLOCK_ID"]])) { $mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]); if (is_array($mxResult)) { $arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"]; } } if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0) { static $arCacheOfferProperties = array(); if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]])) { $dbOfferProperties = CIBlock::GetProperties($arOffersIblock[$arProduct["IBLOCK_ID"]], array(), array("!XML_ID" => "CML2_LINK")); while ($arOfferProperties = $dbOfferProperties->Fetch()) { $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties; } } $arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]]; $arIblockOfferProps = array(); $arIblockOfferPropsFilter = array(); if (is_array($arOfferProperties)) { foreach ($arOfferProperties as $val) { $arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]); $arIblockOfferPropsFilter[] = $val["CODE"]; } } $arOffers = CIBlockPriceTools::GetOffersArray($arProduct["IBLOCK_ID"], $PRODUCT_ID, array("ID" => "DESC"), array("NAME"), $arIblockOfferPropsFilter, 0, array(), 1, array(), $USER_ID, $LID); $arSku = array(); $minItemPrice = 0; $minItemPriceFormat = ""; $arSkuId = array(); $arImgSku = array(); foreach ($arOffers as $arOffer) { $arSkuId[] = $arOffer['ID']; } if (!empty($arSkuId)) { $res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL")); while ($arOfferImg = $res->GetNext()) { $arImgSku[$arOfferImg["ID"]] = $arOfferImg; } } foreach ($arOffers as $arOffer) { $arPrice = CCatalogProduct::GetOptimalPrice($arOffer['ID'], 1, $arGroups, "N", array(), $LID); if (empty($arPrice)) { break; } elseif (strlen($CURRENCY) > 0) { $arPrice["PRICE"]["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY); if ($arPrice["DISCOUNT_PRICE"] > 0) { $arPrice["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY); } $arPrice["PRICE"]["CURRENCY"] = $CURRENCY; } $arSkuTmp = array(); $arOffer["CAN_BUY"] = "N"; $arCatalogProduct = CCatalogProduct::GetByID($arOffer['ID']); if (!empty($arCatalogProduct)) { if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) { $arOffer["CAN_BUY"] = "N"; } else { $arOffer["CAN_BUY"] = "Y"; } } $arSkuTmp["ImageUrl"] = ''; if ($arOffer["CAN_BUY"] == "Y") { $productImg = ""; if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']])) { if ('' == $PRODUCT_NAME) { $PRODUCT_NAME = $arImgSku[$arOffer['ID']]["~NAME"]; } if ($arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"] != "") { $productImg = $arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"]; } elseif ($arImgSku[$arOffer['ID']]["DETAIL_PICTURE"] != "") { $productImg = $arImgSku[$arOffer['ID']]["DETAIL_PICTURE"]; } if ($productImg == "") { if ($arProduct["PREVIEW_PICTURE"] != "") { $productImg = $arProduct["PREVIEW_PICTURE"]; } elseif ($arProduct["DETAIL_PICTURE"] != "") { $productImg = $arProduct["DETAIL_PICTURE"]; } } if ($productImg != "") { $arFile = CFile::GetFileArray($productImg); $productImg = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false); $arSkuTmp["ImageUrl"] = $productImg["src"]; } } } if ($minItemPrice === 0 || $arPrice["DISCOUNT_PRICE"] < $minItemPrice) { $minItemPrice = $arPrice["DISCOUNT_PRICE"]; $minItemPriceFormat = SaleFormatCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"]); } foreach ($arIblockOfferProps as $arCode) { if (array_key_exists($arCode["CODE"], $arOffer["PROPERTIES"])) { if (is_array($arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"])) { $arSkuTmp[] = implode("/", $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"]); } else { $arSkuTmp[] = $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"]; } } } if (!empty($arCatalogProduct)) { $arSkuTmp["BALANCE"] = $arCatalogProduct["QUANTITY"]; $arSkuTmp["WEIGHT"] = $arCatalogProduct["WEIGHT"]; $arSkuTmp["BARCODE_MULTI"] = $arCatalogProduct["BARCODE_MULTI"]; } else { $arSkuTmp["BALANCE"] = 0; $arSkuTmp["WEIGHT"] = 0; $arSkuTmp["BARCODE_MULTI"] = 'N'; } $urlEdit = CIBlock::GetAdminElementEditLink($arOffer["IBLOCK_ID"], $arOffer['ID'], array('find_section_section' => 0, 'WF' => 'Y')); $discountPercent = 0; $arSkuTmp["USER_ID"] = $USER_ID; $arSkuTmp["ID"] = $arOffer["ID"]; $arSkuTmp["NAME"] = CUtil::JSEscape($arOffer["NAME"]); $arSkuTmp["PRODUCT_NAME"] = CUtil::JSEscape($PRODUCT_NAME); $arSkuTmp["PRODUCT_ID"] = $PRODUCT_ID; $arSkuTmp["LID"] = CUtil::JSEscape($LID); $arSkuTmp["MIN_PRICE"] = $minItemPriceFormat; $arSkuTmp["URL_EDIT"] = $urlEdit; $arSkuTmp["DISCOUNT_PRICE"] = ''; $arSkuTmp["DISCOUNT_PRICE_FORMATED"] = ''; $arSkuTmp["PRICE"] = $arPrice["PRICE"]["PRICE"]; $arSkuTmp["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], false); $arPriceType = GetCatalogGroup($arPrice["PRICE"]["CATALOG_GROUP_ID"]); $arSkuTmp["PRICE_TYPE"] = $arPriceType["NAME_LANG"]; $arSkuTmp["VAT_RATE"] = $arPrice["PRICE"]["VAT_RATE"]; if (count($arPrice["DISCOUNT"]) > 0) { $discountPercent = IntVal($arPrice["DISCOUNT"]["VALUE"]); $arSkuTmp["DISCOUNT_PRICE"] = $arPrice["DISCOUNT_PRICE"]; $arSkuTmp["DISCOUNT_PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], false); } $arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]); $arSkuTmp["VALUTA_FORMAT"] = str_replace("#", '', $arCurFormat["FORMAT_STRING"]); $arSkuTmp["DISCOUNT_PERCENT"] = $discountPercent; $arSkuTmp["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"]; $arSkuTmp["CAN_BUY"] = $arOffer["CAN_BUY"]; $arSku[] = $arSkuTmp; } if ((!is_array($arIblockOfferProps) || empty($arIblockOfferProps)) && is_array($arSku) && !empty($arSku)) { $arIblockOfferProps[0] = array("CODE" => "TITLE", "NAME" => GetMessage("SKU_TITLE")); foreach ($arSku as $key => $val) { $arSku[$key][0] = $val["NAME"]; } } $arResult["SKU_ELEMENTS"] = $arSku; $arResult["SKU_PROPERTIES"] = $arIblockOfferProps; $arResult["OFFERS_IBLOCK_ID"] = $arOffersIblock[$arProduct["IBLOCK_ID"]]; } //if OFFERS_IBLOCK_ID > 0 return $arResult; }
die; } if (!CModule::IncludeModule("sale")) { ShowError(GetMessage("SAP_MODULE_NOT_INSTALL")); return; } $arParams["ID"] = IntVal($arParams["ID"]); if ($arParams["ID"] <= 0) { return; } $arParams["ELEMENT_COUNT"] = IntVal($arParams["ELEMENT_COUNT"]); $arParams["MIN_BUYES"] = IntVal($arParams["MIN_BUYES"]); if ($arParams["MIN_BUYES"] <= 0) { $arParams["MIN_BUYES"] = 2; } if ($arParams["ELEMENT_COUNT"] <= 0) { $arParams["ELEMENT_COUNT"] = 5; } $arParams['CONVERT_CURRENCY'] = isset($arParams['CONVERT_CURRENCY']) && 'Y' == $arParams['CONVERT_CURRENCY'] ? 'Y' : 'N'; $arParams['CURRENCY_ID'] = trim(strval($arParams['CURRENCY_ID'])); if ('' == $arParams['CURRENCY_ID']) { $arParams['CONVERT_CURRENCY'] = 'N'; } elseif ('N' == $arParams['CONVERT_CURRENCY']) { $arParams['CURRENCY_ID'] = ''; } $arResult = array(); $dbRes = CSaleProduct::GetProductList($arParams["ID"], $arParams["MIN_BUYES"], $arParams["ELEMENT_COUNT"] * 2); while ($arRes = $dbRes->Fetch()) { $arResult["ID"][] = $arRes["PARENT_PRODUCT_ID"]; } $this->IncludeComponentTemplate();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("sale_prod_search_nav"))); $arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("SOPS_ACTIVE"), "sort" => "ACTIVE", "default" => true), array("id" => "NAME", "content" => GetMessage("SPS_NAME"), "sort" => "name", "default" => true), array("id" => "QUANTITY", "content" => GetMessage("SOPS_QUANTITY"), "default" => true), array("id" => "BALANCE", "content" => GetMessage("SOPS_BALANCE"), "sort" => "", "default" => true, "align" => "right"), array("id" => "PRICE", "content" => GetMessage("SOPS_PRICE"), "default" => true, "align" => "right"), array("id" => "ACT", "content" => " ", "default" => true)); $lAdmin->AddHeaders($arHeaders); $arDiscountCoupons = array(); if (CModule::IncludeModule("sale") && strlen($LID) > 0) { $BASE_LANG_CURR = CSaleLang::GetLangCurrency($LID); $arCurFormat = CCurrencyLang::GetCurrencyFormat($BASE_LANG_CURR); $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]); } $arSku = array(); $OfferIblockId = ""; $aReplace = array(" ", "\\", "'", "\"", "\r\n", "\r", "\n", " "); $aSearch = array(" ", "\\\\", "\\'", '\\"', "\n", "\n", "\\n'+\n'", "\\n'+\n'"); while ($arItems = $dbResultList->Fetch()) { $row =& $lAdmin->AddRow($arItems["ID"], $arItems); $arResult = CSaleProduct::GetProductSku($BUYER_ID, $LID, $arItems["ID"], $arItems["NAME"]); if (count($arResult["SKU_ELEMENTS"]) > 0) { $OfferIblockId = $arResult["OFFERS_IBLOCK_ID"]; $row->AddField("PRICE", GetMessage("SPS_PROCE_FROM") . " " . $arResult["SKU_ELEMENTS"][0]["MIN_PRICE"]); $row->AddField("ACTIVE", ' '); $skuTmp = array(); foreach ($arResult["SKU_ELEMENTS"] as $val) { $skuTmp[] = array("ID" => $val["ID"]); } $row->AddField("ACT", "<input type='button' onClick=\"fShowSku(this, " . CUtil::PhpToJSObject($skuTmp) . ");\" name='btn_show_sku_" . $arItems["ID"] . "' value='" . GetMessage("SPS_SKU_SHOW") . "' >"); // echo "<pre>"; print_r($arResult["SKU_ELEMENTS"]); echo "</pre>"; foreach ($arResult["SKU_ELEMENTS"] as $val) { $skuProperty = ""; $arSkuProperty = array(); foreach ($val as $kk => $vv) { if (is_int($kk) && strlen($vv) > 0) {
$arFilterRes = ${$arParams["FILTER_NAME"]}; if (!is_array($arFilter)) { $arFilterRes = array(); } } $arOrderFilterRes = array(">=DATE_ALLOW_DELIVERY" => ConvertTimeStamp(AddToTimeStamp(array("DD" => "-" . $arParams["days"]))), "=ALLOW_DELIVERY" => "Y", "=LID" => SITE_ID); if (strlen($arParams["ORDER_FILTER_NAME"]) >= 0 && preg_match("/^[A-Za-z_][A-Za-z01-9_]*\$/", $arParams["ORDER_FILTER_NAME"])) { global ${$arParams["ORDER_FILTER_NAME"]}; if (is_array(${$arParams["ORDER_FILTER_NAME"]})) { foreach (${$arParams["ORDER_FILTER_NAME"]} as $k => $v) { $arOrderFilterRes[$k] = $v; } } } $i = 0; $dbRes = CSaleProduct::GetBestSellerList($arParams["by_val"], $arFilterRes, $arOrderFilterRes, $arParams["ITEM_COUNT"] * 2); while ($arRes = $dbRes->GetNext()) { $arFilterIB = array("SITE_ID" => SITE_ID, "ID" => $arRes["PRODUCT_ID"], "ACTIVE" => "Y"); if (strlen($arRes["CATALOG_XML_ID"]) > 0) { $arFilterIB["IBLOCK_EXTERNAL_ID"] = $arRes["CATALOG_XML_ID"]; } $arResult["PRODUCT"][] = $arRes; $dbItem = CIBlockElement::GetList(array(), $arFilterIB, false, array("nTopCount" => 1), array("ID", "IBLOCK_ID", "NAME", "DETAIL_PAGE_URL")); $dbItem->SetUrlTemplates($arParams["DETAIL_URL"]); if ($arItem = $dbItem->GetNext()) { $arResTmp = $arItem; $i++; $arResult["ELEMENT"][] = $arResTmp; } if ($i >= $arParams["ITEM_COUNT"]) { break;
$dbBasket = CSaleBasket::GetList(array("ID" => "DESC"), array("ORDER_ID" => "NULL", "USER_ID" => $str_USER_ID, "LID" => $LID, "PRODUCT_ID" => $arItems["ID"]), false, false, array("ID")); $arBasket = $dbBasket->Fetch(); if ($arBasket && count($arBasket) > 0) { $arBasket["PROPS"] = array(); $arBasketFilter = array("BASKET_ID" => $arBasket["ID"]); if ($bXmlId == "N") { $arBasketFilter["!CODE"] = array("PRODUCT.XML_ID", "CATALOG.XML_ID"); } $dbBasketProps = CSaleBasket::GetPropsList(array("SORT" => "ASC", "NAME" => "ASC"), $arBasketFilter, false, false, array("ID", "BASKET_ID", "NAME", "VALUE", "CODE", "SORT")); while ($arBasketProps = $dbBasketProps->GetNext()) { $arSkuProps[$arBasketProps["NAME"]] = $arBasketProps["VALUE"]; } } //select props from product sku if (count($arSkuProps) <= 0) { $arSkuProps = CSaleProduct::GetProductSkuProps($arItems["ID"], $arItems["IBLOCK_ID"]); } if ($arItems["PREVIEW_PICTURE"] == "" && $arItems["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$arItems["ID"]])) { $idTmp = $arSkuParentChildren[$arItems["ID"]]; $arItems["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"]; $arItems["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"]; } if ($arItems["PREVIEW_PICTURE"] != "") { $productImg = $arItems["PREVIEW_PICTURE"]; } elseif ($arItems["DETAIL_PICTURE"] != "") { $productImg = $arItems["DETAIL_PICTURE"]; } $ImgUrl = ""; if ($productImg != "") { $arFile = CFile::GetFileArray($productImg); $productImg = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
/** * @override * @return integer[] */ protected function getProductIds() { $productIds = array(); $productIterator = CSaleProduct::GetProductList($this->arParams["ID"], $this->arParams["MIN_BUYES"], $this->arParams["PAGE_ELEMENT_COUNT"], true); if ($productIterator) { global $CACHE_MANAGER; $CACHE_MANAGER->RegisterTag("sale_product_buy"); while ($product = $productIterator->fetch()) { $productIds[] = $product['PARENT_PRODUCT_ID']; } } return $productIds; }
/** * @param $productId * @param $quantity * @param $userId * @param $LID * @param $userColumns * @param string $tmpId we can suggest that this mean the set_item * @return array * @throws Main\LoaderException */ protected function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "") { $isSetItem = $tmpId != ""; if (self::$catalogIncluded === null) { self::$catalogIncluded = Main\Loader::includeModule('catalog'); } if (!self::$catalogIncluded) { return array(); } $arParams = array(); static $proxyIblockElement = array(); static $proxyCatalogMeasure = array(); static $proxyParent = array(); static $proxyIblockProperty = array(); static $proxyProductData = array(); static $proxyCatalogProduct = array(); static $proxyCatalogMeasureRatio = array(); $productId = (int) $productId; if ($productId <= 0) { return $arParams; } if (!empty($proxyIblockElement[$productId])) { $iblockId = $proxyIblockElement[$productId]; } else { $iblockId = (int) \CIBlockElement::getIBlockByID($productId); if ($iblockId > 0) { $proxyIblockElement[$productId] = $iblockId; } } if ($iblockId <= 0) { return $arParams; } $arSku2Parent = array(); $arElementId = array(); $arElementId[] = $productId; $proxyParentKey = $productId . "|" . $iblockId; if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey])) { $arParent = $proxyParent[$proxyParentKey]; } else { $arParent = \CCatalogSku::getProductInfo($productId, $iblockId); $proxyParent[$proxyParentKey] = $arParent; } if ($arParent) { $arElementId[] = $arParent["ID"]; $arSku2Parent[$productId] = $arParent["ID"]; } $arPropertyInfo = array(); $userColumns = (string) $userColumns; $arUserColumns = $userColumns != '' ? explode(",", $userColumns) : array(); foreach ($arUserColumns as $key => $column) { if (strncmp($column, 'PROPERTY_', 9) != 0) { unset($arUserColumns[$key]); } else { $propertyCode = substr($column, 9); if ($propertyCode == '') { unset($arUserColumns[$key]); continue; } if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode])) { $arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode]; } else { $dbres = \CIBlockProperty::GetList(array(), array("CODE" => $propertyCode)); if ($arPropData = $dbres->GetNext()) { $arPropertyInfo[$column] = $arPropData; $proxyIblockProperty[$propertyCode] = $arPropData; } } } } $arSelect = array_merge(array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "XML_ID", "IBLOCK_XML_ID"), $arUserColumns); $proxyProductDataKey = md5(join('|', $arElementId) . "_" . join('|', $arSelect)); if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey])) { $arProductData = $proxyProductData[$proxyProductDataKey]; } else { $arProductData = getProductProps($arElementId, $arSelect); $proxyProductData[$proxyProductDataKey] = $arProductData; } $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true); if (!empty($arProductData)) { $arElementInfo = array(); foreach ($arProductData as $elemId => &$arElement) { foreach ($arElement as $key => $value) { if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE") { $columnCode = str_replace("_VALUE", "", $key); $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90)); } } } unset($arElement); if (isset($arProductData[$productId])) { $arElementInfo = $arProductData[$productId]; } if (isset($arSku2Parent[$productId])) { $arParent = $arProductData[$arSku2Parent[$productId]]; } if (!empty($arSku2Parent)) { 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]))) { $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')); } static $buyersGroups = array(); if (empty($buyersGroups[$userId])) { $buyersGroups[$userId] = \CUser::getUserGroup($userId); } $arBuyerGroups = $buyersGroups[$userId]; // price $currentVatMode = \CCatalogProduct::getPriceVatIncludeMode(); $currentUseDiscount = \CCatalogProduct::getUseDiscount(); \CCatalogProduct::setUseDiscount(!$isSetItem); \CCatalogProduct::setPriceVatIncludeMode(true); \CCatalogProduct::setUsedCurrency(Sale\Internals\SiteCurrencyTable::getSiteCurrency($LID)); $arPrice = \CCatalogProduct::getOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID); \CCatalogProduct::clearUsedCurrency(); \CCatalogProduct::setPriceVatIncludeMode($currentVatMode); \CCatalogProduct::setUseDiscount($currentUseDiscount); unset($currentUseDiscount, $currentVatMode); $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE']; $arElementInfo['PRICE'] = $currentPrice; $arElementInfo['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY']; $currentTotalPrice = $arPrice['RESULT_PRICE']['BASE_PRICE']; $arProduct = array(); if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId])) { $arProduct = $proxyCatalogProduct[$productId]; } else { $rsProducts = \CCatalogProduct::getList(array(), array('ID' => $productId), false, false, array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')); if ($arProduct = $rsProducts->Fetch()) { $proxyCatalogProduct[$productId] = $arProduct; } } if (empty($arProduct) || !is_array($arProduct)) { 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']); static $proxySkuProperty = array(); if (!empty($proxySkuProperty[$productId]) && is_array($proxySkuProperty[$productId])) { $arSkuProperty = $proxySkuProperty[$productId]; } else { $arSkuProperty = \CSaleProduct::GetProductSkuProps($productId, '', true); $proxySkuProperty[$productId] = $arSkuProperty; } 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"]); $arElementInfo["WEIGHT"] = $arProduct["WEIGHT"]; // measure $arElementInfo["MEASURE_TEXT"] = ""; $arElementInfo["MEASURE_CODE"] = 0; if ((int) $arProduct["MEASURE"] > 0) { if (!empty($proxyCatalogMeasure[$arProduct["MEASURE"]]) && is_array($proxyCatalogMeasure[$arProduct["MEASURE"]])) { $arMeasure = $proxyCatalogMeasure[$arProduct["MEASURE"]]; } else { $dbMeasure = \CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL")); if ($arMeasure = $dbMeasure->Fetch()) { $proxyCatalogMeasure[$arProduct["MEASURE"]] = $arMeasure; } } if (!empty($arMeasure) && is_array($arMeasure)) { $arElementInfo["MEASURE_TEXT"] = $arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]; $arElementInfo["MEASURE_CODE"] = $arMeasure["CODE"]; } } if ($arElementInfo["MEASURE_TEXT"] == '') { $arElementInfo["MEASURE_TEXT"] = $defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]; } // ratio $arElementInfo["RATIO"] = 1; if (!empty($proxyCatalogMeasureRatio[$productId]) && is_array($proxyCatalogMeasureRatio[$productId])) { $arRatio = $proxyCatalogMeasureRatio[$productId]; } else { $dbratio = \CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId)); if ($arRatio = $dbratio->Fetch()) { $proxyCatalogMeasureRatio[$productId] = $arRatio; } } if (!empty($arRatio) && is_array($arRatio)) { $arElementInfo["RATIO"] = $arRatio["RATIO"]; } // image $imgCode = ''; $imgUrl = ''; 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 = self::getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call // re-define some fields with set data values $arSetItemParams["PARENT_OFFER_ID"] = $productId; $arSetItemParams["OFFER_ID"] = $setItem["PRODUCT_ID"]; $arSetItemParams["NAME"] = $setItem["NAME"]; $arSetItemParams["MODULE"] = $setItem["MODULE"]; $arSetItemParams["PRODUCT_PROVIDER_CLASS"] = $setItem["PRODUCT_PROVIDER_CLASS"]; $arSetItemParams["QUANTITY"] = $setItem["QUANTITY"] * $quantity; $arSetItemParams["BARCODE_MULTI"] = $setItem["BARCODE_MULTI"]; $arSetItemParams["PRODUCT_TYPE"] = $setItem["TYPE"]; $arSetItemParams["WEIGHT"] = $setItem["WEIGHT"]; $arSetItemParams["VAT_RATE"] = $setItem["VAT_RATE"]; $arSetItemParams["SET_ITEMS"] = ""; $arSetItemParams["OLD_PARENT_ID"] = $productId . "_tmp" . $tmpId; $arSetItemParams["IS_SET_ITEM"] = "Y"; $arSetItemParams["IS_SET_PARENT"] = "N"; $arSetItemParams["PROVIDER_DATA"] = serialize($setItem); $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 = (double) $currentTotalPrice; // params array $arParams["OFFER_ID"] = $productId; $arParams["NAME"] = $arElementInfo["~NAME"]; $arParams["EDIT_PAGE_URL"] = $arElementInfo["EDIT_PAGE_URL"]; $arParams["DETAIL_PAGE_URL"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]); $arParams["PICTURE_URL"] = $imgUrl; $arParams["PRICE"] = floatval($arElementInfo["PRICE"]); $arParams["PRICE_BASE"] = $currentTotalPrice; $arParams["DIMENSIONS"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"])); $arParams["QUANTITY"] = $quantity; $arParams["MODULE"] = $arElementInfo["MODULE"]; $arParams["CURRENCY"] = $arElementInfo["CURRENCY"]; $arParams["WEIGHT"] = $arElementInfo["WEIGHT"]; $arParams["VAT_RATE"] = $arPrice["PRICE"]["VAT_RATE"]; $arParams["PRICE_TYPE"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"]; $arParams["AVAILABLE"] = $balance; $arParams["NOTES"] = !empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : ""; $arParams["CATALOG_XML_ID"] = $arElementInfo["~IBLOCK_XML_ID"]; $arParams["PRODUCT_XML_ID"] = $arElementInfo["~XML_ID"]; $arParams["PRODUCT_PROVIDER_CLASS"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"]; $arParams["PROPS"] = $arSkuData; $arParams["MEASURE_TEXT"] = $arElementInfo["MEASURE_TEXT"]; $arParams["MEASURE_CODE"] = $arElementInfo["MEASURE_CODE"]; $arParams["MEASURE_RATIO"] = $arElementInfo["RATIO"]; $arParams["BARCODE_MULTI"] = $arProduct["BARCODE_MULTI"]; $arParams["PRODUCT_TYPE"] = empty($arSetInfo) ? "" : \CSaleBasket::TYPE_SET; $arParams["OLD_PARENT_ID"] = empty($arSetInfo) ? "" : $productId . "_tmp" . $tmpId; $arParams["SET_ITEMS"] = $arSetInfo; $arParams["IS_SET_ITEM"] = "N"; $arParams["IS_SET_PARENT"] = empty($arSetInfo) ? "N" : "Y"; $arParams["STORES"] = empty($arSetInfo) ? $arStores : array(); $arParams["PRODUCT_PROPS_VALUES"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps) } return $arParams; }
} $row->AddField("NAME", $name); $QUANTITY = " "; if (isset($arViews["QUANTITY"])) { $QUANTITY = $arViews["QUANTITY"]; } $row->AddField("QUANTITY", $QUANTITY); $price = " "; if (floatval($arViews["PRICE"]) > 0) { $price = SaleFormatCurrency($arViews["PRICE"], $arViews["CURRENCY"]); } $row->AddField("PRICE", $price); if (count($arSites) > 1) { $row->AddField("LID", "[" . $arViews["LID"] . "] " . htmlspecialcharsbx($arSites[$arViews["LID"]]["NAME"]) . ""); } $arResult = CSaleProduct::GetProductSku($ID, $arViews['SITE_ID'], $arViews["PRODUCT_ID"], $arViews["NAME"]); $arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD_TO_ORDER" => GetMessage('BUYER_PD_ORDER'), "PRODUCT_ADD_TO_BASKET" => GetMessage('BUYER_PD_DELAY_N'), "PRODUCT_NOT_TO_ORDER" => GetMessage('BUYER_DONT_CAN_BUY'), "PRODUCT_PRICE_FROM" => GetMessage('BUYERS_FROM')); if (count($arResult["SKU_ELEMENTS"]) > 0) { $linkOrder = "showOfferPopup(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'order', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");"; $linkBasket = "showOfferPopup(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'basket', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");"; } else { $linkOrder = 'BX.adminPanel.Redirect([], \'/bitrix/admin/sale_order_create.php?USER_ID=' . $ID . '&lang=' . LANG . '&SITE_ID=' . $arViews["SITE_ID"] . '&product[' . $arViews["PRODUCT_ID"] . ']=1\', event);'; $linkBasket = 'fAddToBasketViewed(' . $arViews["PRODUCT_ID"] . ', \'' . $arViews["SITE_ID"] . '\')'; } $arActions = array(); $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("BUYER_PD_ORDER"), "ACTION" => $linkOrder, "DEFAULT" => true); $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("BUYER_PD_DELAY_N"), "ACTION" => $linkBasket); if (floatval($arViews["PRICE"]) > 0) { $row->AddActions($arActions); } }
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; }
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; }
if (!isset($arGadgetParams["LIMIT"]) || (int) $arGadgetParams["LIMIT"] <= 0) { $arGadgetParams["LIMIT"] = 5; } $obCache = new CPHPCache(); $cache_id = "admin_products_" . md5(serialize($arFilter)) . "_" . $arGadgetParams["LIMIT"]; if ($obCache->InitCache($cache_time, $cache_id, "/")) { $arResult = $obCache->GetVars(); } else { $cacheStart = false; if ($cache_time > 0) { $cacheStart = $obCache->StartDataCache(); } $arResult = array(); $arResult["SEL"] = array(); $arFilter["PAYED"] = "Y"; $dbR = CSaleProduct::GetBestSellerList("AMOUNT", array(), $arFilter, $arGadgetParams["LIMIT"]); while ($arR = $dbR->Fetch()) { $arResult["SEL"][] = $arR; } // VIEWED $arResult["VIEWED"] = array(); if (!Loader::includeModule("catalog")) { return; } $arFilter[">=DATE_VISIT"] = $arFilter[">=DATE_INSERT"]; unset($arFilter[">=DATE_INSERT"]); if (isset($arFilter['LID'])) { $arFilter['SITE_ID'] = $arFilter['LID']; unset($arFilter['LID']); } unset($arFilter['PAYED']);