57 if (!$this->visibleColumns)
61 $this->weightUnit = htmlspecialcharsbx(Option::get(
'sale',
'weight_unit',
"", $this->order->getSiteId()));
62 $this->weightKoef = floatval(Option::get(
'sale',
'weight_koef', 1, $this->order->getSiteId()));
64 if($this->weightKoef <= 0)
65 $this->weightKoef = 1;
67 $this->isShowXmlId = Option::get(
"sale",
"show_order_product_xml_id",
"N") ==
"Y";
69 if($jsObjName <>
'' && $idPrefix <>
'')
74 "ID_PREFIX" => $this->idPrefix,
75 "SETTINGS_DLG_OBJECT_NAME" =>
$jsObjName.
".settingsDialog",
76 "ALL_COLUMNS" => array_merge(
77 static::getDefaultVisibleColumns(),
78 getAdditionalColumns(),
79 array(
'NUMBER' =>
Loc::getMessage(
'SALE_ORDER_BASKET_SETTINGS_COL_NUMBER'))
81 "VISIBLE_COLUMNS" => $this->visibleColumns
88 $this->settingsDialog->setShowPropsVisible($isVisible);
97 public function getEdit($defTails =
false)
99 $productAddBool = Option::get(
'sale',
'SALE_ADMIN_NEW_PRODUCT',
'N');
100 $siteId = htmlspecialcharsbx(
102 $this->order->getSiteId()
106 <div class="adm-s-gray-title" style="padding-right: 2px;">
107 '.Loc::getMessage(
"SALE_ORDER_BASKET_COMPOSITION").
'
108 <div class="adm-s-gray-title-btn-container">
110 class="adm-btn adm-btn-green adm-btn-add"
111 onClick="'.$this->jsObjName.
'.addProductSearch({lang: \''.LANGUAGE_ID.
'\', siteId: \
''.$siteId.
'\', orderId:
'.intval($this->order->getId()).'});
"
113 Loc::getMessage("SALE_ORDER_BASKET_PRODUCT_ADD
").
116 <div class="clb
"></div>
120 <div class="adm-s-order-table-ddi
">
121 <table class="adm-s-order-table-ddi-table
" style="width: 100%;
" id="'.$this->idPrefix.'sale_order_edit_product_table
">
122 <thead style="text-align: left;
">
124 <td class="adm-s-order-table-context-menu-column
">
125 <span class="adm-s-order-table-title-icon
"
126 title="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_BUTTON_TITLE").'"
127 onclick="'.$this->jsObjName.'.onHeadMenu(
this);
"
132 foreach($this->visibleColumns as $name)
133 $result .= "<td>
".htmlspecialcharsbx($name)."</td>
";
141 <tbody style="border: 1px solid rgb(221, 221, 221);
" id="'.$this->idPrefix.'sale-adm-order-basket-loading-row
">
143 <td colspan="'.(count($this->visibleColumns)+1).'" style="padding: 20px;
">
144 <img src="/
bitrix/images/sale/admin-loader.gif
"/>
151 <tbody style="border: 1px solid rgb(221, 221, 221);
'.($defTails ? ' display:none;
' : '').'" id="'.$this->idPrefix.'sale-adm-order-edit-basket-empty-row
">
153 <td colspan="'.(count($this->visibleColumns)+1).'" style="padding: 20px;
">
154 '.Loc::getMessage("SALE_ORDER_BASKET_EMPTY_ROW
").'.
162 <div class="adm-s-gray-title
" style="padding-right: 2px;
">
163 <div class="adm-s-gray-title-btn-container
">
165 class="adm-btn adm-btn-green
"
166 onClick="BX.Sale.Admin.OrderAjaxer.sendRequest(
BX.Sale.Admin.OrderEditPage.ajaxRequests.refreshOrderData({operation: \
'DATA_ACTUALIZE\'}));"
167 >'.Loc::getMessage(
'SALE_ORDER_BASKET_ACTUALIZE_DATA').
'</span> -->';
169 if($productAddBool ==
"Y")
172 class="adm-btn adm-btn-green adm-btn-add"
173 onClick="'.$this->jsObjName.
'.productEditDialog.show();"
175 Loc::getMessage(
"SALE_ORDER_BASKET_PRODUCT_NEW").
180 class="adm-btn adm-btn-green adm-btn-add"
181 onClick="'.$this->jsObjName.
'.addProductSearch({lang: \''.LANGUAGE_ID.
'\', siteId: \
''.$siteId.
'\', index: 1, orderId: '.intval($this->order->getId()).
'});"
183 Loc::getMessage(
"SALE_ORDER_BASKET_PRODUCT_ADD").
186 <div class="clb"></div>
188 <input type="hidden" name="BASKET[ID_PREFIX]" value="'.$this->idPrefix.
'">
189 <div class="adm-s-result-container">';
195 <div class="clb"></div>';
201 return $order->getPrice() - $order->getTaxValue() - $order->getDiscountPrice() - $order->getDeliveryPrice();
206 $currency = $this->order->getCurrency();
207 $basket = $this->order->getBasket();
211 if ((
float)$totalPrices[
'ORDER_DISCOUNT_VALUE'] > 0)
213 $orderDiscount =
'<tr>
214 <td>'.Loc::getMessage(
"SALE_ORDER_DEPRECATED_DISCOUNT_VALUE").
'</td>
215 <td id="'.$this->idPrefix.
'sale_order_edit_basket_order_discount">'.
216 \CCurrencyLang::currencyFormat(floatval($totalPrices[
"ORDER_DISCOUNT_VALUE"]), $currency,
true).
222 $weight = $basket->getWeight();
227 <div class="adm-s-result-container-itog">
228 <table class="adm-s-result-container-itog-table">
230 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_PRICE").
'</td>
231 <td id="'.$this->idPrefix.
'sale_order_edit_basket_price_basket">'.
232 \CCurrencyLang::currencyFormat(floatval($totalPrices[
"PRICE_BASKET"]), $currency,
true).
236 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_PRICE_DISCOUNT").
'</td>
237 <td id="'.$this->idPrefix.
'sale_order_edit_basket_price_discount">'.
238 \CCurrencyLang::currencyFormat(floatval($totalPrices[
"PRICE_BASKET_DISCOUNTED"]), $currency,
true).
242 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_PRICE_DELIVERY").
'</td>
243 <td id="'.$this->idPrefix.
'sale_order_edit_basket_price_delivery">'.
244 \CCurrencyLang::currencyFormat(floatval($totalPrices[
"PRICE_DELIVERY"]), $currency,
true).
248 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_PRICE_DELIVERY_DISCOUNT").
'</td>
249 <td id="'.$this->idPrefix.
'sale_order_edit_basket_price_delivery_discount">'.
250 \CCurrencyLang::currencyFormat(floatval($totalPrices[
"PRICE_DELIVERY_DISCOUNTED"]), $currency,
true).
256 <td id="'.$this->idPrefix.
'sale_order_edit_basket_tax">'.
257 \CCurrencyLang::currencyFormat(floatval($totalPrices[
"TAX_VALUE"]), $currency,
true).
261 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_WEIGHT").
'</td>
262 <td id="'.$this->idPrefix.
'sale_order_edit_basket_weight">'.
263 roundEx(floatval($weight/$this->weightKoef), SALE_WEIGHT_PRECISION).
" ".$this->weightUnit.
267 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_PAID").
'</td>
268 <td id="'.$this->idPrefix.
'sale_order_edit_summ_paid">'.
269 \CCurrencyLang::currencyFormat(
270 floatval($totalPrices[
"SUM_PAID"]),
276 <tr class="adm-s-result-container-itog-table-result">
277 <td>'.Loc::getMessage(
"SALE_ORDER_BASKET_PRICE_TOTAL").
'</td>
278 <td id="'.$this->idPrefix.
'sale_order_edit_basket_price_total">'.
279 \CCurrencyLang::currencyFormat(
280 floatval($totalPrices[
"SUM_UNPAID"]),
296 if($mode == self::VIEW_MODE)
298 $discounts = OrderEdit::getDiscountsApplyResult($this->order, $needRecalculate);
299 $showBlock = !empty($discounts[
"COUPON_LIST"]);
305 if ($this->order->getId() > 0 && !($this->order instanceof
Sale\Archive\
Order))
306 $couponMessage =
'<br><div class="bx-adm-pc-section" style="font-size: smaller;">'.Loc::getMessage(
'SALE_ORDER_BASKET_COUPONS_NOTE').
'</div>';
309 <div class="adm-s-result-container-promo">
310 <div class="bx-adm-promocode-container">
311 <div class="bx-adm-pc-section">
312 <div class="bx-adm-pc-title">'.Loc::getMessage(
"SALE_ORDER_BASKET_PROMO").
'</div>'.
313 ($mode == self::EDIT_MODE ?
314 '<div class="bx-adm-pc-inputs-container">
315 <input type="text" class="bx-adm-pc-inout-text" id="sale-admin-order-coupons">
316 <input type="submit" class="bx-adm-pc-input-submit" value='.Loc::getMessage(
"SALE_ORDER_BASKET_ADD").
' onclick="BX.Sale.Admin.OrderBasketCoupons.onAddCoupons(); return false;">
317 </div>'.$couponMessage :
'').
319 <div class="bx-adm-pc-section">
320 <ul class="bx-adm-pc-sale-list" id="sale-admin-order-coupons-container">
325 unset($couponMessage);
342 <div class="adm-s-order-table-ddi">
343 <table class="adm-s-order-table-ddi-table" style="width: 100%;" id="'.$this->idPrefix.
'sale_order_view_product_table">
344 <thead style="text-align: left;">
347 foreach($this->visibleColumns as $colId => $name)
349 $result .=
"<td>".htmlspecialcharsbx($name).
"</td>";
354 <tbody style="border: 1px solid rgb(221, 221, 221);" id="'.$this->idPrefix.
'sale-adm-order-basket-loading-row">
356 <td colspan="'.(count($this->visibleColumns)+1).
'" style="padding: 20px;">
357 <img src="/bitrix/images/sale/admin-loader.gif"/>
361 <tbody style="border: 1px solid rgb(221, 221, 221); display:none;" id="'.$this->idPrefix.
'sale-adm-order-edit-basket-empty-row">
363 <td colspan="'.(count($this->visibleColumns)+1).
'" style="padding: 20px;">
370 <div class="adm-s-result-container">';
372 $result .= $this->getCouponsHtml(self::VIEW_MODE,
false);
373 $result .= $this->getTotalHtml(
false);
376 <div class="clb"></div>';
389 if(!static::$jsInited)
391 \Bitrix\Main\Page\Asset::getInstance()->addJs(
"/bitrix/js/sale/admin/order_basket.js");
392 static::$jsInited =
true;
395 $langPhrases = array(
"SALE_ORDER_BASKET_TURN",
"SALE_ORDER_BASKET_EXPAND",
"SALE_ORDER_BASKET_UP_RATIO",
396 "SALE_ORDER_BASKET_PROD_EDIT",
"SALE_ORDER_BASKET_DOWN_RATIO",
"SALE_ORDER_BASKET_PROD_COUNT",
397 "SALE_ORDER_BASKET_NO_PICTURE",
"SALE_ORDER_BASKET_PROD_CREATE",
"SALE_ORDER_BASKET_ROW_SETTINGS",
398 "SALE_ORDER_BASKET_PROD_MENU_EDIT",
"SALE_ORDER_BASKET_PROD_MENU_DELETE",
"SALE_ORDER_BASKET_BASE_CATALOG_PRICE",
399 "SALE_ORDER_BASKET_PROD_EDIT_ITEM_SAVE",
"SALE_ORDER_BASKET_KG",
"SALE_ORDER_BASKET_COUPON",
400 "SALE_ORDER_BASKET_COUPON_STATUS",
"SALE_ORDER_BASKET_COUPON_APPLY",
"SALE_ORDER_BASKET_COUPON_DELETE",
401 "SALE_ORDER_BASKET_POSITION_EXISTS",
"SALE_ORDER_BASKET_ADD_COUPON_ERROR",
"SALE_ORDER_BASKET_NO_NAME",
402 "SALE_ORDER_BASKET_PRODUCT_UNAVAILABLE"
404 $result =
'<script type="text/javascript">';
406 foreach($langPhrases as $phrase)
407 $result .=
' BX.message({'.$phrase.
': "'.\CUtil::jsEscape(
Loc::getMessage($phrase)).
'"});';
410 $data = static::prepareData();
413 $weight = $this->order->getBasket() ? $this->order->getBasket()->getWeight() : 0;
415 if($this->mode == self::EDIT_MODE)
421 tableId: "'.$this->idPrefix.
'sale_order_edit_product_table",
422 idPrefix: "'.$this->idPrefix.
'",
423 visibleColumns: '.\CUtil::phpToJSObject($this->visibleColumns).
',
424 objName: "'.$this->jsObjName.
'",
425 createProductBasement: '.($this->createProductBasement ?
'true' :
'false').
',
426 columnsCount: '.count($this->visibleColumns).
',
427 createBasketBottom: true,
428 isShowXmlId: '.($this->isShowXmlId ?
'true' :
'false').
',
431 unRemovableFields: ["PRICE", "QUANTITY"],
432 formatQuantity: "'.Option::get(
'sale',
'format_quantity',
'AUTO').
'",
433 weightUnit: "'.$this->weightUnit.
'",
434 '.$this->getTotalBlockFieldsJs($totalPrices, array(
"WEIGHT" => $weight)).
'
440 obParams.productsOrder = '.\CUtil::phpToJSObject($data[
"ITEMS_ORDER"] ?? []).
';
441 obParams.products = '.\CUtil::phpToJSObject($data[
"ITEMS"] ?? []).
';
442 obParams.iblocksSkuParams = '.\CUtil::phpToJSObject($data[
"IBLOCKS_SKU_PARAMS"] ?? []).
';
443 obParams.iblocksSkuParamsOrder = '.\CUtil::phpToJSObject($data[
"IBLOCKS_SKU_PARAMS_ORDER"] ?? []).
';';
447 $this->jsObjName.
'= new BX.Sale.Admin.OrderBasketEdit(obParams);
448 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( '.$this->jsObjName.
'.getFieldsUpdaters() );
450 BX.Sale.Admin.OrderBasketCoupons.mode = BX.Sale.Admin.OrderBasketCoupons.MODES_LIST.'.($this->order->getId() > 0 ?
'EDIT' :
'CREATE').
';
451 BX.Sale.Admin.OrderBasketCoupons.setCoupons('.
452 \CUtil::phpToJSObject(
458 $result .= $this->settingsDialog->getScripts();
467 tableId: "'.$this->idPrefix.
'sale_order_view_product_table",
468 idPrefix: "'.$this->idPrefix.
'",
469 visibleColumns: '.\CUtil::phpToJSObject($this->visibleColumns).
',
470 objName: "'.$this->jsObjName.
'",
471 createProductBasement: '.($this->createProductBasement ?
'true' :
'false').
',
472 columnsCount: '.count($this->visibleColumns).
',
473 isShowXmlId: '.($this->isShowXmlId ?
'true' :
'false').
',
475 createBasketBottom: true,
477 showProps: '.($showProps ?
'true' :
'false').
',
478 formatQuantity: "'.Option::get(
'sale',
'format_quantity',
'AUTO').
'",
479 weightUnit: "'.$this->weightUnit.
'",
480 '.$this->getTotalBlockFieldsJs($totalPrices, array(
"WEIGHT" => $weight)).
'
486 obParams.productsOrder = '.\CUtil::phpToJSObject($data[
"ITEMS_ORDER"]).
';
487 obParams.products = '.\CUtil::phpToJSObject($data[
"ITEMS"]).
';
488 obParams.iblocksSkuParams = '.\CUtil::phpToJSObject($data[
"IBLOCKS_SKU_PARAMS"]).
';
489 obParams.iblocksSkuParamsOrder = '.\CUtil::phpToJSObject($data[
"IBLOCKS_SKU_PARAMS_ORDER"]).
';';
493 $this->jsObjName.
'= new BX.Sale.Admin.OrderBasket(obParams);
494 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( '.$this->jsObjName.
'.getFieldsUpdaters() );
495 BX.Sale.Admin.OrderBasketCoupons.mode = BX.Sale.Admin.OrderBasketCoupons.MODES_LIST.VIEW;
496 BX.Sale.Admin.OrderBasketCoupons.setCoupons('.
497 \CUtil::phpToJSObject(
503 $result .= $this->settingsDialog->getScripts();
506 $result .=
'</script>';
515 id: "'.$this->idPrefix.
'sale_order_edit_basket_price_basket",
516 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"PRICE_BASKET"], $this->order->getCurrency()).
'",
519 PRICE_BASKET_DISCOUNTED: {
520 id: "'.$this->idPrefix.
'sale_order_edit_basket_price_discount",
521 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"PRICE_BASKET_DISCOUNTED"], $this->order->getCurrency()).
'",
525 id: "'.$this->idPrefix.
'sale_order_edit_basket_price_delivery",
526 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"PRICE_DELIVERY"], $this->order->getCurrency()).
'",
529 PRICE_DELIVERY_DISCOUNTED: {
530 id: "'.$this->idPrefix.
'sale_order_edit_basket_price_delivery_discount",
531 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"PRICE_DELIVERY_DISCOUNTED"], $this->order->getCurrency()).
'",
535 id: "'.$this->idPrefix.
'sale_order_edit_basket_tax",
536 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"TAX_VALUE"], $this->order->getCurrency()).
'",
540 id: "'.$this->idPrefix.
'sale_order_edit_basket_weight",
541 value: "'.roundEx(floatval($data[
"WEIGHT"]), SALE_WEIGHT_PRECISION).
'",
545 id: "'.$this->idPrefix.
'sale_order_edit_summ_paid",
546 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"SUM_PAID"], $this->order->getCurrency()).
'",
551 id: "'.$this->idPrefix.
'sale_order_edit_basket_price_total",
552 value: "'.Sale\PriceMaths::roundByFormatCurrency($totalPrices[
"SUM_UNPAID"], $this->order->getCurrency()).
'",
567 foreach($products as $product)
569 if($product[
'PRODUCT_ID'] == $productId && intval($product[
'OFFER_ID']) > 0)
571 $result[] = $product[
'OFFER_ID'];
580 return static::getOffersSkuParamsMode($productsParams, $visibleColumns, $this->mode);
592 if(!empty($productsParams[
"ITEMS"]) && is_array($productsParams[
"ITEMS"]))
594 if (self::$catalogIncluded ===
null)
595 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
596 if (!self::$catalogIncluded)
597 return $productsParams;
599 $iblockPropsUsed = array();
600 $productIds = array();
601 $existOffers = array();
602 $skuFilter = array(
'ID' => array());
603 $propFilter = array(
'ID' => array());
606 foreach($productsParams[
"ITEMS"] as $params)
608 if($params[
'MODULE'] !=
'catalog')
611 $productIds[] = $params[
'PRODUCT_ID'];
613 if ($mode == self::VIEW_MODE)
615 if ((
int)$params[
'OFFER_ID'] > 0)
617 $skuFilter[
'ID'][] = $params[
'OFFER_ID'];
621 if (!isset($ibs[$params[
"IBLOCK_ID"]]))
623 $props = static::getSkuProps(
true, $params[
"IBLOCK_ID"]);
626 foreach($props as $prop)
628 $propFilter[
'ID'][] = $prop[
'ID'];
632 $ibs[$params[
"IBLOCK_ID"]] =
true;
635 if($params[
"PRODUCT_ID"] != $params[
"OFFER_ID"])
636 $existOffers[] = $params[
"OFFER_ID"];
639 $skuFilter[
'ID'] = array_unique($skuFilter[
'ID']);
640 $productIds = array_unique($productIds);
641 $propFilter[
'ID'] = array_unique($propFilter[
'ID']);
643 $allOffers = \CCatalogSKU::getOffersList(
647 array(
'NAME',
"ACTIVE",
'CATALOG_QUANTITY'),
651 $tmpPropsOff = array();
653 if(!empty($allOffers))
654 $tmpPropsOff = static::getPropsFromOffers2($allOffers, $existOffers);
656 unset($skuFilter, $propFilter, $existOffers, $productIds);
658 foreach($productsParams[
"ITEMS"] as &$params)
660 if($params[
'MODULE'] !=
'catalog')
663 if (!isset(self::$productsOffersSkuParams[$params[
"PRODUCT_ID"]]))
665 if(isset($tmpPropsOff[$params[
"PRODUCT_ID"]]))
667 self::$productsOffersSkuParams[$params[
"PRODUCT_ID"]] = $tmpPropsOff[$params[
"PRODUCT_ID"]];
669 foreach($tmpPropsOff[$params[
"PRODUCT_ID"]] as $offerId => $propsList)
671 foreach($propsList as $propId => $propValue)
673 if(!isset($iblockPropsUsed[$propId]))
674 $iblockPropsUsed[$propId] = array();
676 if(is_array($propValue))
678 $iblockPropsUsed[$propId] = array_merge(
679 $iblockPropsUsed[$propId],
682 $iblockPropsUsed[$propId]
688 if(!in_array($propValue, $iblockPropsUsed[$propId]))
689 $iblockPropsUsed[$propId][] = $propValue;
697 unset($allOffers, $tmpPropsOff);
698 $possibleSkuParams = array();
700 foreach($productsParams[
"ITEMS"] as &$params)
702 if($params[
'MODULE'] !=
'catalog')
705 $possibleSku = array();
707 if(intval($params[
"OFFERS_IBLOCK_ID"]) > 0 && !isset(self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]]))
709 self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]] = static::getPropsParams(
710 $params[
"OFFERS_IBLOCK_ID"],
716 if (!empty(self::$productsOffersSkuParams[$params[
"PRODUCT_ID"]][$params[
"OFFER_ID"]]))
718 $params[
"SKU_PROPS"] = self::$productsOffersSkuParams[$params[
"PRODUCT_ID"]][$params[
"OFFER_ID"]];
722 isset($params[
"SKU_PROPS"])
723 && is_array($params[
"SKU_PROPS"])
726 foreach ($params[
"SKU_PROPS"] as $id => $skuProps)
728 if(is_array($skuProps))
730 unset($params[
"SKU_PROPS"][$id]);
734 $params[
"SKU_PROPS"][$id] = array(
736 'NAME' => self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]][$id][
'NAME'],
737 'VALUE' => self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]][$id][
'VALUES'][$skuProps],
738 'CODE' => self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]][$id][
'CODE'],
739 'SORT' => self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]][$id][
'SORT']
742 $possibleSku[$id] = self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]][$id][
'VALUES'][$skuProps][
'ID'];
746 if($mode == self::EDIT_MODE && $params[
'PRODUCT_ID'] != $params[
'OFFER_ID'])
748 if(is_array(self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]]))
749 $skuOrder = array_keys(self::$iblockPropsParams[$params[
"OFFERS_IBLOCK_ID"]]);
751 $skuOrder = array_keys($possibleSku);
753 $possibleSkuParams[$params[
'OFFER_ID']] = array(
754 'PRODUCT_ID' => $params[
'PRODUCT_ID'],
755 'OFFER_ID' => $params[
'OFFER_ID'],
756 'SKU_PROPS' => $possibleSku,
757 'SKU_ORDER' => $skuOrder
762 unset($params, $iblockPropsUsed);
764 if($mode == self::EDIT_MODE && !empty($possibleSkuParams))
766 $possibleSkuProps = Sale\Helpers\Admin\SkuProps::getPossibleSkuPropsValues($possibleSkuParams);
768 if(!empty($possibleSkuProps))
770 foreach($productsParams[
"ITEMS"] as $key => $params)
772 if($params[
'MODULE'] !=
'catalog')
775 $productsParams[
"ITEMS"][$key][
"SKU_PROPS_POSSIBLE_VALUES"] = $possibleSkuProps[$params[
'OFFER_ID']] ?? [];
778 unset($possibleSkuParams);
782 $productsParams[
"IBLOCKS_SKU_PARAMS"] = self::$iblockPropsParams;
784 foreach(self::$iblockPropsParams as $iBlockId => $props)
785 self::$iblockPropsParamsOrder[$iBlockId] = array_keys($props);
788 $productsParams[
"IBLOCKS_SKU_PARAMS_ORDER"] = self::$iblockPropsParamsOrder;
789 return $productsParams;
803 public static function getProductDetails($productId, $quantity, $userId, $siteId, array $columns = array())
808 if($result ===
false)
811 if($result ===
false)
813 if (self::$catalogIncluded ===
null)
814 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
815 if (!self::$catalogIncluded)
818 $result = self::getProductDataToFillBasket($productId, $quantity, $userId, $siteId, implode(
",",array_keys($columns)));
820 static $proxyProductData = array();
822 if (!empty($proxyProductData[$productId]) && is_array($proxyProductData[$productId]))
824 $productInfo = $proxyProductData[$productId];
828 $productInfo = \CCatalogSku::getProductInfo($productId);
829 $proxyProductData[$productId] = $productInfo;
832 if($productInfo !=
false)
834 $result[
"OFFERS_IBLOCK_ID"] = $productInfo[
"OFFER_IBLOCK_ID"];
835 $result[
"IBLOCK_ID"] = $productInfo[
"IBLOCK_ID"];
836 $result[
"PRODUCT_ID"] = $productInfo[
"ID"];
840 $result[
"OFFERS_IBLOCK_ID"] = 0;
841 $result[
"IBLOCK_ID"] = $result[
"PRODUCT_PROPS_VALUES"][
"IBLOCK_ID"];
842 $result[
"PRODUCT_ID"] = $result[
"PRODUCT_PROPS_VALUES"][
"ID"];
860 public static function getProductsData(array $productsIds, $siteId, array $fields = array(), $userId = 0)
862 if(empty($productsIds))
867 foreach($productsIds as $id)
871 if($details !==
false)
872 $result[$id] = $details;
875 $noCachedProductIds = array_diff($productsIds, array_keys($result));
877 if(!empty($noCachedProductIds))
879 $noCachedData = \Bitrix\Sale\Helpers\Admin\Product::getData($noCachedProductIds, $siteId, array_keys($fields));
881 foreach($noCachedData as $productId => $productData)
883 $result[$productId] = $productData;
887 $emptyData = array_diff($productsIds, array_keys($result));
889 foreach($emptyData as $productId)
890 $result[$productId] = array();
896 protected static function getPropsParams($iblockId, array $visibleColumns = array(), array $iblockPropsUsed = array())
899 $bUseHLIblock = \Bitrix\Main\Loader::includeModule(
'highloadblock');
901 '=IBLOCK_ID' => intval($iblockId),
905 if(!empty($iblockPropsUsed))
907 $filter[
'ID'] = array_keys($iblockPropsUsed);
910 if(!empty($visibleColumns))
912 $iBlockProps = array();
913 $iBlockPropsInt = array();
915 foreach ($visibleColumns as $id => $name)
917 if (mb_substr($id, 0, 9) ==
"PROPERTY_")
919 $iblockPropCode = mb_substr($id, 9);
921 if($iblockPropCode <>
'')
923 $iBlockProps[] = $iblockPropCode;
925 if(intval($iblockPropCode) > 0)
926 $iBlockPropsInt[] = intval($iblockPropCode);
931 if(!empty($iBlockProps) || !empty($iBlockPropsInt))
933 $codes = array(
'LOGIC' =>
'OR');
935 if(!empty($iBlockProps))
936 $codes[
'=CODE'] = $iBlockProps;
938 if(!empty($iBlockPropsInt))
939 $codes[
'=ID'] = $iBlockPropsInt;
945 $rsProps = \Bitrix\Iblock\PropertyTable::getList(array(
947 'order' => array(
'SORT' =>
'ASC',
'ID' =>
'ASC'),
950 while ($arProp = $rsProps->fetch())
952 if(!empty($iblockPropsUsed) && !array_key_exists($arProp[
'ID'], $iblockPropsUsed))
956 $arProp[
'PROPERTY_TYPE'] ==
'L'
957 || $arProp[
'PROPERTY_TYPE'] ==
'E'
958 || ($arProp[
'PROPERTY_TYPE'] ==
'S' && $arProp[
'USER_TYPE'] ==
'directory')
961 if ($arProp[
'XML_ID'] ==
'CML2_LINK')
966 if ($arProp[
'PROPERTY_TYPE'] ==
'L')
969 $rsPropEnums = \CIBlockProperty::getPropertyEnum($arProp[
'ID']);
970 while ($arEnum = $rsPropEnums->fetch())
972 $arValues[$arEnum[
'VALUE']] = array(
973 'ID' => $arEnum[
'ID'],
974 'NAME' => $arEnum[
'VALUE'],
979 elseif ($arProp[
'PROPERTY_TYPE'] ==
'E')
981 $eFilter = array(
'IBLOCK_ID' => $arProp[
'LINK_IBLOCK_ID'],
'ACTIVE' =>
'Y');
983 if(!empty($iblockPropsUsed[$arProp[
'ID']]))
984 $eFilter[
'ID'] = $iblockPropsUsed[$arProp[
'ID']];
988 $rsPropEnums = \CIBlockElement::getList(
989 array(
'SORT' =>
'ASC'),
993 array(
'ID',
'NAME',
'PREVIEW_PICTURE',
'SORT')
996 while ($arEnum = $rsPropEnums->Fetch())
998 $arEnum[
'PREVIEW_PICTURE'] = \CFile::getFileArray($arEnum[
'PREVIEW_PICTURE']);
1000 if (!is_array($arEnum[
'PREVIEW_PICTURE']))
1002 $arEnum[
'PREVIEW_PICTURE'] =
false;
1005 if ($arEnum[
'PREVIEW_PICTURE'] !==
false)
1007 $productImg = \CFile::resizeImageGet($arEnum[
'PREVIEW_PICTURE'], array(
'width'=>80,
'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL,
false,
false);
1008 $arEnum[
'PREVIEW_PICTURE'] = $productImg[
'src'];
1011 $arValues[$arEnum[
'ID']] = array(
1012 'ID' => $arEnum[
'ID'],
1013 'NAME' => $arEnum[
'NAME'],
1014 'SORT' => $arEnum[
'SORT'],
1015 'PICT' => $arEnum[
'PREVIEW_PICTURE']
1019 elseif ($arProp[
'PROPERTY_TYPE'] ==
'S' && $arProp[
'USER_TYPE'] ==
'directory')
1023 if(!is_array($arProp[
"USER_TYPE_SETTINGS"]))
1024 $arProp[
"USER_TYPE_SETTINGS"] = unserialize($arProp[
"USER_TYPE_SETTINGS"], [
'allowed_classes' =>
false]);
1026 $hlblock = HL\HighloadBlockTable::getList(array(
"filter" => array(
"TABLE_NAME" => $arProp[
"USER_TYPE_SETTINGS"][
"TABLE_NAME"])))->fetch();
1029 $entity = HL\HighloadBlockTable::compileEntity($hlblock);
1030 $entityDataClass = $entity->getDataClass();
1031 $rsData = $entityDataClass::getList();
1033 while ($arData = $rsData->fetch())
1035 $arValues[$arData[
'UF_XML_ID']] = array(
1036 'ID' => $arData[
'UF_XML_ID'],
1037 'NAME' => $arData[
'UF_NAME'],
1038 'SORT' => $arData[
'UF_SORT'],
1039 'FILE' => $arData[
'UF_FILE'],
1041 'XML_ID' => $arData[
'UF_XML_ID']
1050 isset($iblockPropsUsed[$arProp[
'ID']])
1051 && is_array($iblockPropsUsed[$arProp[
'ID']])
1052 && !empty($arValues)
1053 && is_array($arValues)
1057 $notFound = array_diff($iblockPropsUsed[$arProp[
'ID']], array_keys($arValues));
1060 if((is_array($iblockPropsUsed[$arProp[
'ID']]) && in_array(
"-", $iblockPropsUsed[$arProp[
'ID']])) || (is_array($notFound) && !empty($notFound)))
1062 $arValues[
"-"] = array(
1068 $arRes[$arProp[
'ID']] = array(
1069 'ID' => $arProp[
'ID'],
1070 'CODE' => $arProp[
'CODE'],
1071 'NAME' => $arProp[
'NAME'],
1072 'TYPE' => $arProp[
'PROPERTY_TYPE'],
1073 'ORDER' => array_keys($arValues),
1074 'VALUES' => $arValues,
1075 'SORT' => $arProp[
'SORT']
1081 $arProp[
'PROPERTY_TYPE'] ==
"S"
1082 && $arProp[
'USER_TYPE'] ==
'directory'
1083 && isset($arRes[$arProp[
'ID']][
'VALUES'])
1084 && is_array($arRes[$arProp[
'ID']][
'VALUES'])
1087 foreach($arRes[$arProp[
'ID']][
'VALUES'] as $id => $value)
1089 if (isset($value[
"FILE"]))
1091 $arTmpFile = \CFile::getFileArray($value[
"FILE"]);
1092 $tmpImg = \CFile::resizeImageGet(
1098 BX_RESIZE_IMAGE_PROPORTIONAL,
1102 $arRes[$arProp[
'ID']][
'VALUES'][$id][
'PICT'] = $tmpImg[
'src'];
1114 $notEmptyProps = array();
1115 $allProps = array();
1117 foreach($items as $id => $item)
1119 if(!isset($props[$id]))
1120 $props[$id] = array();
1122 foreach($item as $offerId => $offer)
1124 if(!isset($offer[
"PROPERTIES"]))
1127 if(!in_array($offerId, $existOffers) && $offer[
"ACTIVE"] !=
"Y")
1130 if(!isset($props[$id][$offerId]))
1131 $props[$id][$offerId] = array();
1133 foreach($offer[
"PROPERTIES"] as $propCode => $propParams)
1135 if($propParams[
"MULTIPLE"] ==
"Y")
1138 if($propParams[
"ACTIVE"] !=
"Y")
1141 if($propParams[
'PROPERTY_TYPE'] ==
'L'
1142 || $propParams[
'PROPERTY_TYPE'] ==
'E'
1144 $propParams[
'PROPERTY_TYPE'] ==
'S'
1145 && $propParams[
'USER_TYPE'] ==
'directory'
1149 if(!in_array($propParams[
"ID"], $allProps))
1150 $allProps[] = $propParams[
"ID"];
1152 if($propParams[
"~VALUE"] <>
'')
1154 $props[$id][$offerId][$propParams[
"ID"]] = $propParams[
"~VALUE"];
1156 if(!in_array($propParams[
"ID"], $notEmptyProps))
1157 $notEmptyProps[] = $propParams[
"ID"];
1161 $props[$id][$offerId][$propParams[
"ID"]] =
"-";
1168 $emptyProps = array_diff($allProps, $notEmptyProps);
1170 if(!empty($emptyProps))
1172 foreach($emptyProps as $propId)
1174 foreach($props as $prodId => $offers)
1176 foreach($offers as $offerId => $offerProps)
1178 unset($props[$prodId][$offerId][$propId]);
1189 if (!isset(static::$arSkuProps[$iblockId]))
1191 $arCatalog = static::getOffersCatalog($iblockId);
1192 static::$arSkuProps[$iblockId] = $arCatalog? static::getPropsList($arCatalog[
"IBLOCK_ID"], $arCatalog[
'SKU_PROPERTY_ID']) : array();
1194 return $flagAll? static::$arSkuProps[$iblockId] : static::filterProps(static::$arSkuProps[$iblockId]);
1199 if (self::$catalogIncluded ===
null)
1200 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
1201 if (!self::$catalogIncluded)
1204 if (!isset(static::$offersCatalog[$iblockId]))
1205 static::$offersCatalog[$iblockId] = \CCatalogSKU::getInfoByProductIBlock($iblockId);
1207 return static::$offersCatalog[$iblockId];
1212 if (self::$catalogIncluded ===
null)
1213 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
1214 if (!self::$catalogIncluded)
1217 $propertyIds = Catalog\Product\PropertyCatalogFeature::getOfferTreePropertyCodes($iblockId);
1218 if ($propertyIds ===
null)
1222 '@ID' => $propertyIds,
1223 '=IBLOCK_ID' => $iblockId,
1225 if ($skuPropertyId > 0)
1226 $filter[
'!=ID'] = $skuPropertyId;
1227 $iterator = Iblock\PropertyTable::getList(array(
1228 'select' => array(
'*'),
1229 'filter' => $filter,
1235 while ($row = $iterator->fetch())
1237 $row[
'USER_TYPE'] = (string)$row[
'USER_TYPE'];
1238 $row[
'~NAME'] = $row[
'NAME'];
1239 $row[
'NAME'] = htmlspecialcharsEx($row[
'NAME']);
1240 $row[
'PROPERTY_USER_TYPE'] = ($row[
'USER_TYPE'] !=
'' ? \CIBlockProperty::getUserType($row[
'USER_TYPE']) : array());
1243 unset($row, $iterator);
1253 foreach ($props AS $prop)
1255 if ($prop[
'FILTRABLE'] ==
'Y' && $prop[
'PROPERTY_TYPE'] !=
'F')
1264 return $this->settingsDialog->getHtml();
1269 return \CUserOptions::GetOption($idPrefix.
"order_basket_table",
"table_columns");
1277 "QUANTITY" =>
Loc::getMessage(
"SALE_ORDER_BASKET_SETTINGS_COL_QUANTITY"),
1278 "AVAILABLE" =>
Loc::getMessage(
"SALE_ORDER_BASKET_SETTINGS_COL_AVAILABLE"),
1287 if (self::$iblockIncluded ===
null)
1288 self::$iblockIncluded = Main\Loader::includeModule(
'iblock');
1289 if (!self::$iblockIncluded)
1293 $arTmpColumns = array();
1294 $arColumnsOptions = static::loadVisibleColumns($idPrefix);
1296 if (is_array($arColumnsOptions) && isset($arColumnsOptions[
"columns"]) && $arColumnsOptions[
"columns"] <>
'')
1297 $arTmpColumns = explode(
",", $arColumnsOptions[
"columns"]);
1299 if(is_array($arTmpColumns) && !empty($arTmpColumns))
1301 $iBlockProps = array();
1302 $iBlockPropsInt = array();
1304 foreach ($arTmpColumns as $id => $columnCode)
1306 if (mb_substr($columnCode, 0, 9) ==
"PROPERTY_")
1308 $iblockPropCode = mb_substr($columnCode, 9);
1310 if($iblockPropCode <>
'')
1312 $iBlockProps[] = $iblockPropCode;
1314 if(intval($iblockPropCode) > 0)
1315 $iBlockPropsInt[] = intval($iblockPropCode);
1317 $result[$columnCode] =
"";
1322 $result[$columnCode] =
Loc::getMessage(
"SALE_ORDER_BASKET_SETTINGS_COL_".$columnCode);
1326 if(!empty($iBlockProps))
1328 $dbRes = \Bitrix\Iblock\PropertyTable::getList(array(
1331 '=CODE' => $iBlockProps,
1332 '=ID' => $iBlockPropsInt
1334 'select' => array(
'ID',
'NAME',
'CODE')
1337 while($arPropData = $dbRes->fetch())
1339 if($arPropData[
'CODE'] <>
'')
1340 $result[
"PROPERTY_".$arPropData[
'CODE']] = $arPropData[
"NAME"];
1342 $result[
"PROPERTY_".$arPropData[
'ID']] = $arPropData[
"NAME"];
1348 $result = static::getDefaultVisibleColumns();
1357 <input id="FORM_BASKET_PRODUCT_ID" name="BASKET_PRODUCT_ID" value="" type="hidden">
1358 <input id="FORM_PROD_BASKET_CUSTOM_PRICE" name="BASKET_CUSTOM_PRICE" value="Y" type="hidden">
1359 <input id="FORM_PROD_BASKET_BASKET_CODE" name="FORM_PROD_BASKET_BASKET_CODE" value="" type="hidden">
1360 <table class="edit-table">
1362 <td width="40%"> </td>
1363 <td align="left" width="60%">
1364 <div id="basketError" style="display:none;">
1365 <table class="message message-error" border="0" cellpadding="0" cellspacing="0" style="border:2px solid #FF0000;color:#FF0000">
1368 <table class="content" border="0" cellpadding="0" cellspacing="0" style="margin:4px;">
1370 <td valign="top"><div class="icon-error"></div></td>
1372 <span class="message-title" style="font-weight:bold;">'.Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ERROR").
'</span><br>
1373 <div class="empty" style="height: 5px;"></div><div id="basketErrorText"></div>
1382 <tr id="FORM_NEWPROD_CODE">
1383 <td class="adm-detail-content-cell-l" width="30%">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_ID").
':</td>
1384 <td width="70%"><input size="10" id="FORM_PROD_BASKET_OFFER_ID" name="FORM_PROD_BASKET_OFFER_ID" type="text" value="" tabindex="1"></td>
1386 <tr class="adm-detail-required-field">
1387 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_NAME").
':</td>
1388 <td><input size="40" id="FORM_PROD_BASKET_NAME" name="FORM_PROD_BASKET_NAME" type="text" value="" tabindex="2" onkeyup="'.$objName.
'.productEditDialog.disableButton();"></td>
1391 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_PATH").
':</td>
1392 <td><input id="FORM_PROD_BASKET_DETAIL_PAGE_URL" name="FORM_PROD_BASKET_DETAIL_PAGE_URL" value="" size="40" type="text" tabindex="3"></td>
1395 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_CATALOG_XML").
':</td>
1396 <td><input id="FORM_PROD_BASKET_CATALOG_XML_ID" name="FORM_PROD_BASKET_CATALOG_XML_ID" value="" size="40" type="text" tabindex="4"></td>
1399 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_PRODUCT_XML").
':</td>
1400 <td><input id="FORM_PROD_BASKET_PRODUCT_XML_ID" name="FORM_PROD_BASKET_PRODUCT_XML_ID" value="" size="40" type="text" tabindex="5"></td>
1403 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_NOTES").
':</td>
1404 <td><input name="FORM_PROD_BASKET_NOTES" id="FORM_PROD_BASKET_NOTES" size="40" maxlength="250" value="" type="text" tabindex="6"></td>
1407 <td class="adm-detail-content-cell-l" valign="top" width="40%">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_PROPS").
':</td>
1409 <table id="BASKET_PROP_TABLE" class="internal" border="0" cellpadding="3" cellspacing="1" style="width: 521px; margin-top: 20px;">
1410 <tr class="heading" style="border-collapse:collapse;background-color:#E7EAF5;color:#525355;">
1411 <td align="center">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_IP_NAME").
'</td>
1412 <td align="center">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_IP_VALUE").
'</td>
1413 <td align="center">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_IP_CODE").
'</td>
1414 <td align="center">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_IP_SORT").
'</td>
1416 <tr id="FORM_PROD_BASKET_EMPTY_PROP_ROW">
1417 <td colspan="4" style="text-align: center;">
1422 <div width="100%" style="text-align: right;">
1423 <input value="'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_PROPERTY_MORE").
'" onclick="'.$objName.
'.productEditDialog.addPropRow();" type="button" style="margin-top: 10px;">
1427 <tr class="adm-detail-required-field">
1428 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_QUANTITY").
':</td>
1430 <input name="FORM_PROD_BASKET_QUANTITY" id="FORM_PROD_BASKET_QUANTITY" size="10" maxlength="20" value="" type="text" tabindex="7" onkeyup="'.$objName.
'.productEditDialog.disableButton();">
1432 'FORM_PROD_BASKET_MEASURE_CODE',
1433 self::getCatalogMeasures(),
1437 'id' =>
'FORM_PROD_BASKET_MEASURE_CODE',
1438 'onchange' => $objName.
'.productEditDialog.setMeasureText();'
1441 <input name="FORM_PROD_BASKET_MEASURE_TEXT" id="FORM_PROD_BASKET_MEASURE_TEXT" type="hidden" value="">
1444 <tr class="adm-detail-required-field">
1445 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_PRICE").
':</td>
1446 <td><input name="FORM_PROD_BASKET_PRICE" id="FORM_PROD_BASKET_PRICE" size="10" maxlength="20" value="" type="text" tabindex="8" onkeyup="'.$objName.
'.productEditDialog.disableButton();"> ('.\CUtil::JSEscape($currency).
')</td>
1449 <td class="adm-detail-content-cell-l">'.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_WEIGHT").
':</td>
1450 <td><input name="FORM_PROD_BASKET_WEIGHT" id="FORM_PROD_BASKET_WEIGHT" size="10" maxlength="20" value="" type="text" tabindex="9"> ('.
Loc::getMessage(
"SALE_ORDER_BASKET_PROD_EDIT_ITEM_GRAMM").
')</td>
1457 return \Bitrix\Sale\Helpers\Order\Builder\BasketBuilder::getCatalogMeasures();
1462 return \CCatalogMeasure::getDefaultMeasure(
true,
true);
1476 public static function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId =
"")
1478 $isSetItem = $tmpId !=
"";
1480 if (self::$catalogIncluded ===
null)
1481 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
1482 if (!self::$catalogIncluded)
1485 $arParams = array();
1487 static $proxyIblockElement = array();
1488 static $proxyCatalogMeasure = array();
1489 static $proxyParent = array();
1490 static $proxyIblockProperty = array();
1491 static $proxyProductData = array();
1492 static $proxyCatalogProduct = array();
1493 static $proxyCatalogMeasureRatio = array();
1495 $productId = (int)$productId;
1496 if ($productId <= 0)
1501 if (!empty($proxyIblockElement[$productId]))
1503 $iblockId = $proxyIblockElement[$productId];
1507 $iblockId = (int)\CIBlockElement::getIBlockByID($productId);
1510 $proxyIblockElement[$productId] = $iblockId;
1518 $arSku2Parent = array();
1519 $arElementId = array();
1521 $arElementId[] = $productId;
1523 $proxyParentKey = $productId.
"|".$iblockId;
1525 if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey]))
1527 $arParent = $proxyParent[$proxyParentKey];
1531 $arParent = \CCatalogSku::getProductInfo($productId, $iblockId);
1532 $proxyParent[$proxyParentKey] = $arParent;
1538 $arElementId[] = $arParent[
"ID"];
1542 $arPropertyInfo = array();
1543 $userColumns = (string)$userColumns;
1544 $arUserColumns = ($userColumns !=
'') ? explode(
",", $userColumns) : array();
1545 foreach ($arUserColumns as $key => $column)
1547 $column = mb_strtoupper($column);
1548 if (strncmp($column,
'PROPERTY_', 9) != 0)
1550 unset($arUserColumns[$key]);
1554 $propertyCode = mb_substr($column, 9);
1555 if ($propertyCode ==
'')
1557 unset($arUserColumns[$key]);
1561 if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode]))
1563 $arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
1567 $dbres = \CIBlockProperty::getList(array(), array(
"CODE" => $propertyCode));
1568 if ($arPropData = $dbres->getNext())
1570 $arPropertyInfo[$column] = $arPropData;
1571 $proxyIblockProperty[$propertyCode] = $arPropData;
1578 $arSelect = array_merge(
1583 "IBLOCK_SECTION_ID",
1587 "IBLOCK_EXTERNAL_ID",
1593 $proxyProductDataKey = md5(join(
'|', $arElementId).
"_".join(
'|', $arSelect));
1594 if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey]))
1596 $arProductData = $proxyProductData[$proxyProductDataKey];
1600 $arProductData = getProductProps($arElementId, $arSelect);
1601 $proxyProductData[$proxyProductDataKey] = $arProductData;
1604 $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(
true,
true);
1606 if (!empty($arProductData))
1608 $arElementInfo = array();
1609 foreach ($arProductData as $elemId => &$arElement)
1611 foreach ($arElement as $key => $value)
1613 if (strncmp($key,
'PROPERTY_', 9) == 0 && mb_substr($key, -6) ==
"_VALUE")
1615 $columnCode = str_replace(
"_VALUE",
"", $key);
1616 if (!isset($arPropertyInfo[$columnCode]))
1618 $keyResult =
'PROPERTY_'.$arPropertyInfo[$columnCode][
'CODE'].
'_VALUE';
1619 $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array(
"WIDTH" => 90,
"HEIGHT" => 90));
1620 if ($keyResult != $key)
1621 $arElement[$keyResult] = $arElement[$key];
1628 if (isset($arProductData[$productId]))
1631 if (isset( $arSku2Parent[$productId]))
1632 $arParent = $arProductData[$arSku2Parent[
$productId]];
1634 if (!empty($arSku2Parent))
1636 foreach ($arUserColumns as $field)
1638 $fieldVal = $field.
"_VALUE";
1641 if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && $arElementInfo[$fieldVal] ==
''))
1642 && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal])))
1644 $arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
1647 if (mb_strpos($arElementInfo[
"~XML_ID"],
'#') ===
false)
1649 $arElementInfo[
"~XML_ID"] = $arParent[
'~XML_ID'].
'#'.$arElementInfo[
"~XML_ID"];
1653 $arElementInfo[
"MODULE"] =
"catalog";
1654 $arElementInfo[
"PRODUCT_PROVIDER_CLASS"] =
"CCatalogProductProvider";
1656 $arElementInfo[
"PRODUCT_ID"] = $arElementInfo[
"ID"];
1657 if ($arElementInfo[
"IBLOCK_ID"] > 0)
1659 $arElementInfo[
"EDIT_PAGE_URL"] = \CIBlock::GetAdminElementEditLink($arElementInfo[
"IBLOCK_ID"], $arElementInfo[
"PRODUCT_ID"], array(
1660 "find_section_section" => $arElementInfo[
"IBLOCK_SECTION_ID"],
1665 static $buyersGroups = array();
1667 if(empty($buyersGroups[$userId]))
1668 $buyersGroups[
$userId] = \CUser::getUserGroup($userId);
1670 $arBuyerGroups = $buyersGroups[
$userId];
1673 Catalog\Product\Price\Calculation::pushConfig();
1674 Catalog\Product\Price\Calculation::setConfig(array(
1676 'PRECISION' => (
int)Main\
Config\Option::get(
'sale',
'value_precision'),
1677 'USE_DISCOUNTS' => !$isSetItem,
1678 'RESULT_WITH_VAT' =>
true
1680 $arPrice = \CCatalogProduct::getOptimalPrice($arElementInfo[
"ID"], 1, $arBuyerGroups,
"N", array(), $LID);
1681 Catalog\Product\Price\Calculation::popConfig();
1682 $priceType = GetCatalogGroup($arPrice[
"PRICE"][
"CATALOG_GROUP_ID"]);
1684 $currentPrice = $arPrice[
'RESULT_PRICE'][
'DISCOUNT_PRICE'];
1685 $arElementInfo[
'PRICE'] = $currentPrice;
1686 $arElementInfo[
'CURRENCY'] = $arPrice[
'RESULT_PRICE'][
'CURRENCY'];
1687 $currentTotalPrice = $arPrice[
'RESULT_PRICE'][
'BASE_PRICE'];
1689 if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId]))
1691 $arProduct = $proxyCatalogProduct[
$productId];
1695 $rsProducts = Catalog\ProductTable::getList([
1696 'select' => [
'ID',
'QUANTITY',
'WEIGHT',
'MEASURE',
'TYPE',
'BARCODE_MULTI',
'WIDTH',
'LENGTH',
'HEIGHT'],
1697 'filter' => [
'=ID' => $productId]
1699 if ($arProduct = $rsProducts->fetch())
1701 $proxyCatalogProduct[
$productId] = $arProduct;
1706 if (empty($arProduct) || !is_array($arProduct))
1711 $balance = floatval($arProduct[
"QUANTITY"]);
1714 $arSkuData = array();
1716 static $proxySkuProperty = array();
1718 if (!empty($proxySkuProperty[$productId]) && is_array($proxySkuProperty[$productId]))
1720 $arSkuProperty = $proxySkuProperty[
$productId];
1724 $arSkuProperty = \CSaleProduct::GetProductSkuProps($productId,
'',
true);
1725 $proxySkuProperty[
$productId] = $arSkuProperty;
1728 if (!empty($arSkuProperty))
1730 foreach ($arSkuProperty as &$val)
1732 $arSkuData[] = array(
1733 'NAME' => htmlspecialcharsback($val[
'NAME']),
1734 'VALUE' => htmlspecialcharsback($val[
'VALUE']),
1735 'CODE' => htmlspecialcharsback($val[
'CODE'])
1741 if($arElementInfo[
"~IBLOCK_EXTERNAL_ID"] <>
'')
1743 $arSkuData[] = array(
1744 "NAME" =>
"Catalog XML_ID",
1745 "CODE" =>
"CATALOG.XML_ID",
1746 "VALUE" => $arElementInfo[
'~IBLOCK_EXTERNAL_ID']
1750 if($arElementInfo[
"~XML_ID"] <>
'')
1752 $arSkuData[] = array(
1753 "NAME" =>
"Product XML_ID",
1754 "CODE" =>
"PRODUCT.XML_ID",
1755 "VALUE" => $arElementInfo[
"~XML_ID"]
1759 $arElementInfo[
"WEIGHT"] = $arProduct[
"WEIGHT"];
1760 $arElementInfo[
"WIDTH"] = $arProduct[
"WIDTH"];
1761 $arElementInfo[
"LENGTH"] = $arProduct[
"LENGTH"];
1762 $arElementInfo[
"HEIGHT"] = $arProduct[
"HEIGHT"];
1765 $arElementInfo[
"MEASURE_TEXT"] =
"";
1766 $arElementInfo[
"MEASURE_CODE"] = 0;
1768 if ((
int)$arProduct[
"MEASURE"] > 0)
1771 if (!empty($proxyCatalogMeasure[$arProduct[
"MEASURE"]]) && is_array($proxyCatalogMeasure[$arProduct[
"MEASURE"]]))
1773 $arMeasure = $proxyCatalogMeasure[$arProduct[
"MEASURE"]];
1777 $dbMeasure = \CCatalogMeasure::GetList(array(), array(
"ID" => intval($arProduct[
"MEASURE"])),
false,
false, array(
"ID",
"SYMBOL_RUS",
"SYMBOL_INTL"));
1778 if ($arMeasure = $dbMeasure->Fetch())
1780 $proxyCatalogMeasure[$arProduct[
"MEASURE"]] = $arMeasure;
1784 if (!empty($arMeasure) && is_array($arMeasure))
1786 $arElementInfo[
"MEASURE_TEXT"] = ($arMeasure[
"SYMBOL_RUS"] !=
'' ? $arMeasure[
"SYMBOL_RUS"] : $arMeasure[
"SYMBOL_INTL"]);
1787 $arElementInfo[
"MEASURE_CODE"] = $arMeasure[
"CODE"];
1790 if ($arElementInfo[
"MEASURE_TEXT"] ==
'')
1792 $arElementInfo[
"MEASURE_TEXT"] = ($defaultMeasure[
"SYMBOL_RUS"] !=
'' ? $defaultMeasure[
"SYMBOL_RUS"] : $defaultMeasure[
"SYMBOL_INTL"]);
1797 $arElementInfo[
"RATIO"] = 1;
1799 if (!empty($proxyCatalogMeasureRatio[$productId]) && is_array($proxyCatalogMeasureRatio[$productId]))
1801 $arRatio = $proxyCatalogMeasureRatio[
$productId];
1805 $dbratio = Catalog\MeasureRatioTable::getList(array(
1806 'select' => array(
'*'),
1807 'filter' => array(
'=PRODUCT_ID' => $productId,
'=IS_DEFAULT' =>
'Y')
1809 if ($arRatio = $dbratio->fetch())
1811 $proxyCatalogMeasureRatio[
$productId] = $arRatio;
1816 if (!empty($arRatio) && is_array($arRatio))
1817 $arElementInfo[
"RATIO"] = $arRatio[
"RATIO"];
1822 if ($arElementInfo[
"PREVIEW_PICTURE"] > 0)
1823 $imgCode = $arElementInfo[
"PREVIEW_PICTURE"];
1824 elseif ($arElementInfo[
"DETAIL_PICTURE"] > 0)
1825 $imgCode = $arElementInfo["DETAIL_PICTURE"];
1827 if ($imgCode == "" && !empty($arParent) && is_array($arParent))
1829 if ($arParent[
"PREVIEW_PICTURE"] > 0)
1830 $imgCode = $arParent[
"PREVIEW_PICTURE"];
1831 elseif ($arParent[
"DETAIL_PICTURE"] > 0)
1832 $imgCode = $arParent["DETAIL_PICTURE"];
1837 $arFile = \CFile::GetFileArray($imgCode);
1838 $arImgProduct = \CFile::ResizeImageGet($arFile, array(
'width'=>80,
'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL,
false,
false);
1839 if (is_array($arImgProduct))
1840 $imgUrl = $arImgProduct[
"src"];
1843 $arSetInfo = array();
1844 $arStores = array();
1847 if ($productProvider = \CSaleBasket::GetProductProvider(array(
"MODULE" => $arElementInfo[
"MODULE"],
"PRODUCT_PROVIDER_CLASS" => $arElementInfo[
"PRODUCT_PROVIDER_CLASS"])))
1850 if ($arProduct[
"TYPE"] == \CCatalogProduct::TYPE_SET)
1852 if (method_exists($productProvider,
"GetSetItems"))
1854 $arSets = $productProvider::GetSetItems($productId, \CSaleBasket::TYPE_SET);
1857 $tmpId = randString(7);
1859 if (!empty($arSets))
1861 foreach ($arSets as $arSetData)
1863 foreach ($arSetData[
"ITEMS"] as $setItem)
1865 $arSetItemParams = self::getProductDataToFillBasket($setItem[
"PRODUCT_ID"], $setItem[
"QUANTITY"], $userId, $LID, $userColumns, $tmpId);
1868 $arSetItemParams[
"PARENT_OFFER_ID"] =
$productId;
1869 $arSetItemParams[
"OFFER_ID"] = $setItem[
"PRODUCT_ID"];
1870 $arSetItemParams[
"NAME"] = $setItem[
"NAME"];
1871 $arSetItemParams[
"MODULE"] = $setItem[
"MODULE"];
1872 $arSetItemParams[
"PRODUCT_PROVIDER_CLASS"] = $setItem[
"PRODUCT_PROVIDER_CLASS"];
1873 $arSetItemParams[
"QUANTITY"] = $setItem[
"QUANTITY"] * $quantity;
1874 $arSetItemParams[
"BARCODE_MULTI"] = $setItem[
"BARCODE_MULTI"];
1875 $arSetItemParams[
"PRODUCT_TYPE"] = $setItem[
"TYPE"];
1876 $arSetItemParams[
"WEIGHT"] = $setItem[
"WEIGHT"];
1877 $arSetItemParams[
"VAT_RATE"] = $setItem[
"VAT_RATE"];
1878 $arSetItemParams[
"SET_ITEMS"] =
"";
1879 $arSetItemParams[
"OLD_PARENT_ID"] =
$productId.
"_tmp".$tmpId;
1880 $arSetItemParams[
"IS_SET_ITEM"] =
"Y";
1881 $arSetItemParams[
"IS_SET_PARENT"] =
"N";
1882 $arSetItemParams[
"PROVIDER_DATA"] = serialize($setItem);
1883 $arSetInfo[] = $arSetItemParams;
1891 $storeCount = $productProvider::GetStoresCount(array(
"SITE_ID" => $LID));
1893 if ($storeCount > 0)
1895 if ($arProductStore = $productProvider::GetProductStores(array(
"PRODUCT_ID" => $productId,
"SITE_ID" => $LID)))
1896 $arStores = $arProductStore;
1900 $currentTotalPrice = (float)$currentTotalPrice;
1903 $arParams[
"NAME"] = $arElementInfo[
"~NAME"];
1904 $arParams[
"EDIT_PAGE_URL"] = $arElementInfo[
"EDIT_PAGE_URL"];
1905 $arParams[
"DETAIL_PAGE_URL"] = htmlspecialcharsex($arElementInfo[
"~DETAIL_PAGE_URL"]);
1906 $arParams[
"PICTURE_URL"] = $imgUrl;
1907 $arParams[
"PRICE"] = floatval($arElementInfo[
"PRICE"]);
1908 $arParams[
"PRICE_BASE"] = $currentTotalPrice;
1909 $arParams[
"DIMENSIONS"] = serialize(array(
"WIDTH" => $arElementInfo[
"WIDTH"],
"HEIGHT" => $arElementInfo[
"HEIGHT"],
"LENGTH" => $arElementInfo[
"LENGTH"]));
1910 $arParams[
"QUANTITY"] = $quantity;
1911 $arParams[
"MODULE"] = $arElementInfo[
"MODULE"];
1912 $arParams[
"CURRENCY"] = $arElementInfo[
"CURRENCY"];
1913 $arParams[
"WEIGHT"] = $arElementInfo[
"WEIGHT"];
1914 $arParams[
"VAT_RATE"] = $arPrice[
"PRICE"][
"VAT_RATE"];
1915 $arParams[
"PRICE_TYPE"] = $priceType[
"NAME_LANG"];
1916 $arParams[
"AVAILABLE"] = $balance;
1917 $arParams[
"NOTES"] = (!empty($priceType[
"NAME_LANG"]) ? $priceType[
"NAME_LANG"] :
"");
1918 $arParams[
"CATALOG_XML_ID"] = $arElementInfo[
"~IBLOCK_EXTERNAL_ID"];
1919 $arParams[
"PRODUCT_XML_ID"] = $arElementInfo[
"~XML_ID"];
1920 $arParams[
"PRODUCT_PROVIDER_CLASS"] = $arElementInfo[
"PRODUCT_PROVIDER_CLASS"];
1921 $arParams[
"PROPS"] = $arSkuData;
1922 $arParams[
"MEASURE_TEXT"] = $arElementInfo[
"MEASURE_TEXT"];
1923 $arParams[
"MEASURE_CODE"] = $arElementInfo[
"MEASURE_CODE"];
1924 $arParams[
"MEASURE_RATIO"] = $arElementInfo[
"RATIO"];
1925 $arParams[
"BARCODE_MULTI"] = $arProduct[
"BARCODE_MULTI"];
1927 $arParams[
"PRODUCT_TYPE"] = empty($arSetInfo) ?
"" : \CSaleBasket::TYPE_SET;
1928 $arParams[
"OLD_PARENT_ID"] = empty($arSetInfo) ?
"" :
$productId.
"_tmp".$tmpId;
1930 $arParams[
"SET_ITEMS"] = $arSetInfo;
1931 $arParams[
"IS_SET_ITEM"] =
"N";
1932 $arParams[
"IS_SET_PARENT"] = empty($arSetInfo) ?
"N" :
"Y";
1934 $arParams[
"STORES"] = empty($arSetInfo) ? $arStores : array();
1935 $arParams[
"PRODUCT_PROPS_VALUES"] = $arElementInfo;
1947 public function prepareData(array $inParams = array())
1949 if($this->data ===
null)
1951 $inParams[
'ADDED_PRODUCTS'] ??=
null;
1952 $isArrayAddedProducts = is_array($inParams[
'ADDED_PRODUCTS']);
1959 $basket = $this->order->getBasket();
1960 $discounts = !empty($inParams[
"DISCOUNTS"]) ? $inParams[
"DISCOUNTS"] : OrderEdit::getDiscountsApplyResult($this->order,
true);
1964 $result[
"WEIGHT_FOR_HUMAN"] = roundEx(floatval(0), SALE_WEIGHT_PRECISION);
1965 $this->data = $result;
1969 $result[
"WEIGHT"] = $basket->getWeight();
1970 $result[
"WEIGHT_FOR_HUMAN"] = roundEx(floatval($result[
"WEIGHT"]/$this->weightKoef), SALE_WEIGHT_PRECISION);
1971 $items = $basket->getBasketItems();
1973 if (self::$catalogIncluded ===
null)
1974 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
1976 if(!empty($inParams[
"ADDED_PRODUCTS"]))
1977 $result[
"ADDED_PRODUCTS"] = array();
1979 $catalogProductIds = array();
1982 foreach($items as $item)
1983 if($item->getField(
'MODULE') ==
'catalog')
1984 $catalogProductIds[] = $item->getProductId();
1986 $catalogPreparedData = static::getProductsData($catalogProductIds, $this->order->getSiteId(), $this->visibleColumns, $this->order->getUserId());
1990 foreach($items as $item)
1995 $params[
"BASKET_CODE"] = $basketCode = $item->getBasketCode();
1996 $params[
"QUANTITY"] = Sale\BasketItem::formatQuantity($item->getField(
'QUANTITY'));
1997 $params[
"NOTES"] = $item->getField(
"NOTES");
1998 $params[
"MODULE"] = $item->getField(
"MODULE");
1999 $params[
'TYPE'] = (int)$item->getField(
'TYPE');
2001 if($params[
"MODULE"] ==
'catalog')
2003 if(!empty($catalogPreparedData[$productId][
'OFFERS_IBLOCK_ID']))
2004 $params[
"OFFERS_IBLOCK_ID"] = $catalogPreparedData[$productId][
'OFFERS_IBLOCK_ID'];
2006 if(!empty($catalogPreparedData[$productId][
'IBLOCK_ID']))
2007 $params[
"IBLOCK_ID"] = $catalogPreparedData[$productId][
'IBLOCK_ID'];
2009 if(!empty($catalogPreparedData[$productId][
'PRODUCT_ID']))
2010 $params[
"PRODUCT_ID"] = $catalogPreparedData[$productId][
'PRODUCT_ID'];
2013 if(!isset($params[
"OFFER_ID"]))
2014 $params[
"OFFER_ID"] = $productId;
2016 if(isset($discounts[
"RESULT"][
"BASKET"][$basketCode]) && is_array($discounts[
"RESULT"][
"BASKET"][$basketCode]))
2017 foreach($discounts[
"RESULT"][
"BASKET"][$basketCode] as $discount)
2018 $params[
"DISCOUNTS"][$discount[
"DISCOUNT_ID"]] = $discount;
2020 if(isset($discounts[
"PRICES"][
"BASKET"][$basketCode]))
2021 $params[
"PRICE"] = $discounts[
"PRICES"][
"BASKET"][$basketCode][
"PRICE"];
2023 $params[
"PRICE"] = $item->getPrice();
2026 $params[
"PRICE_BASE"] = $params[
"BASE_PRICE"] = $item->getField(
"BASE_PRICE");
2027 $params[
"CUSTOM_PRICE"] = $item->isCustomPrice() ?
"Y" :
"N";
2030 !$isArrayAddedProducts
2033 !empty($inParams[
"ADDED_PRODUCTS"])
2034 && in_array($productId, $inParams[
"ADDED_PRODUCTS"])
2038 $params = $params + self::getPropsForBasketItem($item, $catalogPreparedData);
2040 if ($isArrayAddedProducts && in_array($productId, $inParams[
"ADDED_PRODUCTS"]))
2042 $result[
"ADDED_PRODUCTS"][] = $basketCode;
2049 $basketItem = $basket->getItemByBasketCode($basketCode);
2052 if (!empty($providerData[$basketCode]))
2054 \Bitrix\Sale\Helpers\Admin\OrderEdit::setProviderTrustData($item, $this->order, $providerData[$basketCode]);
2055 $params[
"PROVIDER_DATA"] = serialize($providerData[$basketCode]);
2063 if(is_array($providerData) && !empty($providerData))
2065 $params[
"PROVIDER_DATA"] = serialize($providerData);
2069 if (!empty($params[
"SET_ITEMS"]) && is_array($params[
"SET_ITEMS"]))
2071 $offerToIdx = array();
2073 foreach($params[
"SET_ITEMS"] as $idx => $childFields)
2074 $offerToIdx[$childFields[
"OFFER_ID"]] = $idx;
2078 if($children = $item->getBundleCollection())
2081 foreach($children->getBasketItems() as $idx => $child)
2083 $fields = $child->getFieldValues();
2085 if(isset($offerToIdx[$fields[
'PRODUCT_ID']]))
2087 $fields = $fields + $params[
"SET_ITEMS"][$offerToIdx[$fields[
'PRODUCT_ID']]];
2091 $fields[
"OFFER_ID"] = $fields[
"PRODUCT_ID"];
2094 $fields[
"IS_ENABLED"] = ($fields[
'CAN_BUY'] ===
'N') ?
'N' :
'Y';
2096 $setItems[$idx] = $fields;
2099 $params[
"SET_ITEMS"] = $setItems;
2102 $params[
"SET_ITEMS_DATA"] = serialize($params[
"SET_ITEMS"]);
2104 elseif($item->isBundleParent())
2106 $params[
"SET_ITEMS"] = array();
2108 if($children = $item->getBundleCollection())
2111 foreach($children->getBasketItems() as $child)
2113 $childFields = $child->getFieldValues();
2114 $childFields[
"OFFER_ID"] = $child->getProductId();
2115 $childFields[
"IS_SET_ITEM"] =
"Y";
2116 $childFields[
"IS_SET_PARENT"] =
"N";
2117 $childFields[
"IS_ENABLED"] = ($childFields[
'CAN_BUY'] ===
'N') ?
'N' :
'Y';
2118 $params[
"SET_ITEMS"][] = $childFields;
2122 if(!empty($params[
"SET_ITEMS"]))
2124 $params[
"IS_SET_PARENT"] =
"Y";
2128 $params[
"IS_ENABLED"] = (($params[
'CAN_BUY'] ??
null) ===
'N') ?
'N' :
'Y';
2130 $result[
"ITEMS"][$basketCode] = $params;
2133 $result = array_merge(
2134 $result, $this->getPrices($discounts)
2137 $result[
"ITEMS_ORDER"] = array_keys($result[
"ITEMS"]);
2139 if (empty($inParams[
"SKIP_SKU_INFO"]))
2141 $result = $this->getOffersSkuParams($result, $this->visibleColumns);
2144 $this->data = $result;
2152 static $result =
null;
2154 if($result ===
null)
2157 $basketPriceBase = 0;
2158 $basket = $this->order->getBasket();
2163 $discounts = OrderEdit::getDiscountsApplyResult($this->order,
true);
2165 $basketPriceBase = $basket->getBasePrice();
2166 $basketPrice = $basket->getPrice();
2170 "BASKET_PRICE_BASE" => $basketPriceBase,
2171 "BASKET_PRICE" => $basketPrice,
2174 $result[
"DISCOUNT_VALUE"] = $result[
"BASKET_PRICE_BASE"] - $result[
"BASKET_PRICE"];
2180 protected function getPropsForBasketItem($item, array $preparedData = array())
2185 if (self::$catalogIncluded ===
null)
2186 self::$catalogIncluded = Main\Loader::includeModule(
'catalog');
2188 $productId = $item->getProductId();
2190 if($item->getField(
"MODULE") ==
"catalog")
2192 if(!empty($preparedData[$item->getProductId()]))
2194 $params = $preparedData[$item->getProductId()];
2198 $res = static::getProductsData(array($productId), $this->order->getSiteId(), $this->visibleColumns, $this->order->getUserId());
2199 $params = $res[$productId];
2203 if(intval($item->getField(
"MEASURE_CODE")) > 0)
2204 $params[
"MEASURE_CODE"] = intval($item->getField(
"MEASURE_CODE"));
2205 elseif(!isset($params[
"MEASURE_CODE"]))
2206 $params[
"MEASURE_CODE"] = 0;
2208 if($item->getField(
"MEASURE_NAME") <>
'')
2209 $params[
"MEASURE_TEXT"] = $item->getField(
"MEASURE_NAME");
2210 elseif(!isset($params[
"MEASURE_TEXT"]))
2211 $params[
"MEASURE_TEXT"] =
"";
2213 if(!isset($params[
"OFFER_ID"]))
2214 $params[
"OFFER_ID"] = $productId;
2216 $params[
"PRODUCT_PROVIDER_CLASS"] = $item->getProvider();
2217 $id = $params[
"PRODUCT_ID"] ?? 0;
2218 $params = array_merge($params, $item->getFieldValues(), array(
"PRODUCT_ID" => $id));
2221 if($item->getBasketCode() == intval($item->getBasketCode()) && !$item->isBundleParent() && !empty($params[
'SET_ITEMS']))
2223 unset($params[
'SET_ITEMS'], $params[
'OLD_PARENT_ID']);
2224 $params[
'IS_SET_PARENT'] =
'N';
2227 $params[
"PROPS"] = array();
2230 foreach($item->getPropertyCollection() as $property)
2232 $propKey =
'PROPERTY_'.$property->getField(
"CODE").
'_VALUE';
2234 if(isset($params[
'PRODUCT_PROPS_VALUES'][$propKey]))
2236 $params[
'PRODUCT_PROPS_VALUES'][$propKey] = $property->getField(
"VALUE");
2239 $params[
"PROPS"][] = array(
2240 "VALUE" => $property->getField(
"VALUE"),
2241 "NAME" => $property->getField(
"NAME"),
2242 "CODE" => $property->getField(
"CODE"),
2243 "SORT" => $property->getField(
"SORT"),
2244 "ID" => $property->getField(
"ID")
2253 if(is_array($providerData) && !empty($providerData))
2254 $params[
"PROVIDER_DATA"] = serialize($providerData);
2257 if (!empty($params[
"SET_ITEMS"]) && is_array($params[
"SET_ITEMS"]))
2259 $offerToIdx = array();
2262 foreach($params[
"SET_ITEMS"] as $idx => $childFields)
2263 $offerToIdx[$childFields[
"OFFER_ID"]] = $idx;
2265 if($children = $item->getBundleCollection())
2268 foreach($children->getBasketItems() as $idx => $child)
2270 $fields = $child->getFieldValues();
2272 if(isset($offerToIdx[$fields[
'PRODUCT_ID']]))
2274 $items[$idx] = $fields + $params[
"SET_ITEMS"][$offerToIdx[$fields[
'PRODUCT_ID']]];
2278 $res = static::getProductsData(array($fields[
"PRODUCT_ID"]), $this->order->getSiteId(), $this->visibleColumns, $this->order->getUserId());
2280 if(!empty($res[$fields[
"PRODUCT_ID"]]))
2282 $fields = array_merge($res[$fields[
"PRODUCT_ID"]], $fields);
2285 $fields[
"OFFER_ID"] = $fields[
"PRODUCT_ID"];
2286 $fields[
"IS_SET_ITEM"] =
"Y";
2287 $fields[
"IS_SET_PARENT"] =
"N";
2288 $fields[
"OLD_PARENT_ID"] = $params[
"OLD_PARENT_ID"];
2289 $items[$idx] = $fields;
2293 sortByColumn($items, array(
"SORT" => SORT_DESC),
'');
2294 $params[
"SET_ITEMS"] = $items;
2297 $params[
"SET_ITEMS_DATA"] = serialize($params[
"SET_ITEMS"]);