OrderDealSynchronizer uses FlowTrait
Synchronizer of the products of the order and the deal.
Synchronization works only in the CRM mode without orders and occurs only if the products of the deal or the order are changed.
Mechanics of products synchronization:
- when adding a product to a deal, a new basket item is added to the order, the received item is linked to the
crm
product row: theXML_ID
fields are filled inb_sale_basket
and inb_crm_product_row
; - when editing a product in a deal (price, quantity, discount, the product itself, variation, etc.),
if the product is already in the order (checked by
XML_ID
), then the basket item is updated. Otherwise, a new basket item is added; - when the product is removed from the deal the linked basket item is deleted. If there is no position, then nothing is deleted.
Tags
Table of Contents
Methods
- __construct() : mixed
- createDealFromOrder() : void
- Create deal from order.
- createOrderFromDeal() : void
- Create order from deal.
- syncOrderReservesFromDeal() : void
- Update order reserves from reservations result of deal.
- updateDealFromOrder() : void
- Update deal products from order.
- updateOrderFromDeal() : void
- Update order from deal.
- verifyDealProducts() : Result
- Checking the list of products of the deal, whether they can be saved in the order.
Methods
__construct()
public
__construct([bool|null $isSupportSync = null ]) : mixed
Parameters
- $isSupportSync : bool|null = null
-
if sets
null
- init automatically.
createDealFromOrder()
Create deal from order.
public
createDealFromOrder(Order $order) : void
Don't create new deal if order already binded to deal.
Parameters
- $order : Order
createOrderFromDeal()
Create order from deal.
public
createOrderFromDeal(int $dealId) : void
If the deal is already binded to the order, a new order will not be created and synchronization will not be performed.
Parameters
- $dealId : int
syncOrderReservesFromDeal()
Update order reserves from reservations result of deal.
public
syncOrderReservesFromDeal(int $dealId, ReservationResult $result[, bool $beforeSyncProducts = false ]) : void
If the order not exists, creates it.
Parameters
- $dealId : int
- $result : ReservationResult
- $beforeSyncProducts : bool = false
updateDealFromOrder()
Update deal products from order.
public
updateDealFromOrder(Order $order) : void
A deal is not created if the order is not binded to the deal at the time of synchronization.
Parameters
- $order : Order
updateOrderFromDeal()
Update order from deal.
public
updateOrderFromDeal(int $dealId) : void
If the deal is not binded to the order, a new order will not be created and synchronization will not be performed.
Parameters
- $dealId : int
verifyDealProducts()
Checking the list of products of the deal, whether they can be saved in the order.
public
verifyDealProducts(int $dealId, array<string|int, mixed> $dealProducts) : Result
Parameters
- $dealId : int
- $dealProducts : array<string|int, mixed>