-
Notifications
You must be signed in to change notification settings - Fork 254
Description
Summary (*)
The Append Reservation Plugin only fires when creating an order is triggered via quote management. This leads to issues when a order is created directly. Following the order lifecycle by creating shipments and creditmemo will mix up the reservervations leading to wrongly rendered salable quantities for products.
Examples (*)
For automatically appending new reserverations an around plugin is used:
Lines 100 to 110 in 0208e43
/** | |
* Add inventory reservation before placing synchronous order or if stock reservation is deferred. | |
* | |
* @param OrderManagementInterface $subject | |
* @param callable $proceed | |
* @param OrderInterface $order | |
* @return OrderInterface | |
* @throws \Exception | |
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | |
*/ | |
public function aroundPlace( |
The plugged method:
https://github.com/magento/magento2/blob/2217274eb99b66a2c8e63cb488d0edaceb8f0ae3/app/code/Magento/Sales/Model/Service/OrderService.php#L261
is only used when creating an order via QuoteManagement. An order could also by placed via the order's model itself by using it's own place
function:
https://github.com/magento/magento2/blob/2217274eb99b66a2c8e63cb488d0edaceb8f0ae3/app/code/Magento/Sales/Model/Order.php#L1273
method.
This is even used inside the plugged method eventually:
https://github.com/magento/magento2/blob/2217274eb99b66a2c8e63cb488d0edaceb8f0ae3/app/code/Magento/Sales/Model/Service/OrderService.php#L264
Proposed solution
Since creating an order without going through a quote first is totally legit I suggest changing this, Utlizing the thrown event sales_order_place_after
inside the order's place
method would even be a way cleaner approach, since the order itself is not touched by the mechanism thus using an event is the better approach in my view.
I stumbled upon this when using a third party service that is creating orders as descriped (not via quotes).
Metadata
Metadata
Assignees
Type
Projects
Status