- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/controller/action/entity/saveorderaction.php
- Класс: BitrixSaleControllerActionEntitySaveOrderAction
- Вызов: SaveOrderAction::prepareOrder
private function prepareOrder(array $fields): SaleResult
{
$result = new SaleResult();
$order = $this->createOrder($fields['SITE_ID']);
$personTypeId = (int)$fields['PERSON_TYPE_ID'];
$setPersonTypeIdResult = $this->setPersonTypeId($order, $personTypeId);
if (!$setPersonTypeIdResult->isSuccess())
{
$this->fillErrorCollection(
$result,
$setPersonTypeIdResult->getErrors(),
SaleControllerErrorEnumeration::SAVE_ORDER_ACTION_SET_PERSON_TYPE_ID
);
return $result;
}
if (!empty($fields['TRADING_PLATFORM_ID']))
{
$tradingPlatformId = $fields['TRADING_PLATFORM_ID'];
$setTradeBindingResult = $this->setTradeBinding($order, $tradingPlatformId);
if (!$setTradeBindingResult->isSuccess())
{
$this->fillErrorCollection(
$result,
$setTradeBindingResult->getErrors(),
SaleControllerErrorEnumeration::SAVE_ORDER_ACTION_SET_TRADE_BINDINGS
);
return $result;
}
}
$properties = $fields['PROPERTIES'] ?? null;
if ($properties)
{
$setPropertiesResult = $this->setProperties($order, $properties);
if (!$setPropertiesResult->isSuccess())
{
$this->fillErrorCollection(
$result,
$setPropertiesResult->getErrors(),
SaleControllerErrorEnumeration::SAVE_ORDER_ACTION_SET_PROPERTIES
);
return $result;
}
}
$setBasketResult = $this->setBasket($order, $fields['FUSER_ID']);
if (!$setBasketResult->isSuccess())
{
$this->fillErrorCollection(
$result,
$setBasketResult->getErrors(),
SaleControllerErrorEnumeration::SAVE_ORDER_ACTION_SET_BASKET
);
return $result;
}
if (
MainLoader::includeModule('crm')
&& class_exists(CrmIntegrationCompilationManager::class)
)
{
$this->compilationDealId = CrmIntegrationCompilationManager::processOrderForCompilation($order);
}
$result->setData(['order' => $order]);
return $result;
}