Можно ли как-то вывести у сделок пользовательское поле типа "привязка к элементам highload блока"?
function posts_items($posts){
foreach ($posts as $item) {
// ...
}
// return то что тебе надо получить или то что получилось в цикле
}
function getItemsDate()
{
return posts_items($posts);
}
function getItemsCategory()
{
return posts_items($posts);
}
$bxEventManager = \Bitrix\Main\EventManager::getInstance();
$bxEventManager->addEventHandler(
'sale',
'OnSaleShipmentEntitySaved',
array(
"\\Gricuk\\Shipment",
"onSaleShipmentSavedHandler"
)
);
<?php
namespace Gricuk;
use Bitrix\Main\Event;
use Bitrix\Main\EventResult;
use Bitrix\Main\Result;
class Shipment
{
public static function onSaleShipmentSavedHandler(\Bitrix\Main\Event $event)
{
/** @var \Bitrix\Sale\Shipment $shipment */
$shipment = $event->getParameter("ENTITY");
$oldValues = $event->getParameter("VALUES");
$shipmentFields = $shipment->getFieldValues();
/**
* Ключ - статус ДОСТАВКИ
* Значение - статус ЗАКАЗА
*/
$statusMap = [
"DR" => "F",
"DB" => "RS"
];
if (isset($statusMap[$shipmentFields["STATUS_ID"]])) {
try {
$orderId = $shipment->getParentOrderId();
$order = \Bitrix\Sale\Order::load($orderId);
$order->setField("STATUS_ID", $statusMap[$shipmentFields["STATUS_ID"]]);
/** @var Result $saveResult */
$saveResult = $order->save();
if (!$saveResult->isSuccess()) {
\Bitrix\Main\Diag\Debug::dumpToFile($saveResult, '$saveResult', 'onSaleShipmentSavedHandler.log');
}
} catch (\Exception $e) {
\Bitrix\Main\Diag\Debug::dumpToFile($e, '$e', 'onSaleShipmentSavedHandler.log');
}
}
}
}
foreach ($arResult["ITEMS"] as $arItem) {
$arSelect = Array("ID", "NAME", "IBLOCK_ID");
$arFilter = Array(
"IBLOCK_ID" => $IBLOCK_ID,
"ID" => $arItem["IBLOCK_SECTION_ID"],
);
$res = CIblockSEction::GetList(array("SORT" => "ASC"), $arFilter);
if($arSection = $res->Fetch()) {
}
}