Open norgeindian opened 1 year ago
Hi @norgeindian. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this
Just spent about a day following a stack trace trying to debug this same problem. I see now that someone already figured that out lol.
Sucks to see this hasn't been fixed, but I guess it's not a super common issue to come across. Gonna see if I can code something up to keep the functionality while working around the authorization plugin.
Created a small module to fix the issue. https://github.com/SmartexCanada/magento2-InventoryInStorePickupSalesFix
Adds the following:
\Magento\InventoryInStorePickupSales\Model\SourceSelection\GetActiveStorePickupOrdersBySource::execute
to set that we're processing the source selection request.\Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::afterLoad
to check if we're processing the source selection request, allowing us to ignore thrown error from isAllowed
Preconditions (*)
magento/module-inventory-shipping 1.2.2
2.4.5-p1
Steps to reproduce (*)
sales/minimum_order/active
to 0carriers/instore/active
carriers/instore/price
to0.00
Expected result (*)
Actual result (*)
No entry with orderID = xxx
and the order can not be fulfilled.We debugged that issue for a while and found out, in the end, that the observer
inventory_sales_virtual_source_deduction_processor
is the reason for this issue. The call stack is the following:What happens in the end, is, that the
VirtualSourceDeductionProcessor
starts to create a list of all orders, which still need to be collected from the in-store pickup location. (see\Magento\InventoryInStorePickupSales\Model\SourceSelection\GetActiveStorePickupOrdersBySource::execute
). It fails in the end, when it starts loading these orders. The reason for that is, that free orders are invoiced directly during the checkout process. When the old order A is now loaded, the pluginauthorization
is calling\Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::afterLoad
, which calls\Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::isAllowed
. As the user context is still customer in the checkout, this check returns false, as user B is not allowed to load the order of user A. For virtual products, which cost more than $0, this does not happen, as the invoice process starts later and this way, the check is not run.Our workaround for this issue is to disable the observer completely, as we are lucky and don't need to care about stock in the virtual products of our project. But in general it would be great to find a better solution here to fix this issue properly.