BasketItemsSynchronizer
Synchronize deal products with the basket items.
Main entity for that synchronizer - basket (order).
For example:
$order = \Bitrix\Crm\Order\Order::load($orderId);
$dealProductRows = \Bitrix\Crm\ProductRowTable::getList([
'filter' => [
'=OWNER_TYPE' => CCrmOwnerTypeAbbr::Deal,
'=OWNER_ID' => $dealId,
],
])->fetchAll();
$synchronizer = new \Bitrix\Crm\Order\OrderDealSynchronizer\Products\BasketItemsSynchronizer($order->getBasket(), $dealProductRows);
$resultProductRows = $synchronizer->sync();
$result = $synchronizer->syncAndSave($dealId);
Table of Contents
Methods
- __construct() : mixed
- sync() : array<string|int, mixed>
- Synchronize product rows with basket items.
- syncAndSave() : Result
- Synchronize product rows with basket items, and save deal.
Methods
__construct()
public
__construct(Basket $basket, array<string|int, mixed> $productRows) : mixed
Parameters
- $basket : Basket
- $productRows : array<string|int, mixed>
sync()
Synchronize product rows with basket items.
public
sync() : array<string|int, mixed>
If the basket item contains 'XML_ID' with 'ROW_ID`, this binds it to a row. If the basket item is new, it is skipped because it cannot be linked with the product row.
Return values
array<string|int, mixed> —actual product rows.
syncAndSave()
Synchronize product rows with basket items, and save deal.
public
syncAndSave(int $dealId) : Result
Parameters
- $dealId : int