[Core] Fix inventory unit orphan removement#1186
Conversation
|
Experiencing same issue. Inventory unit doesn't go away even I decrease the item quantity in cart. This result in inventory unit and order content doesn't match. |
|
@kayue Did you try this patch? I think we should consider adding some scenarios, which ensure that Administrator sees correct amount of inventory units in backend. As well as states, this would cover our inventory, which seems to be a bit buggy now. :/ |
|
Will try all this today, that's crazy how I missed it... |
|
@pjedrzejewski This fix works for me :) Thanks @fullpipe |
|
It's all good but we miss inventory units deletion when clearing cart. |
|
@winzou Sorry I can't follow you. When do we "clearing cart"? How to reproduce this? |
|
When user press "clear cart". It deletes anyway the cart so there shouldn't be any confusion on the admin side, but this is still an issue. |
[Core] Fix inventory unit orphan removement
|
I think I found the problem. |
|
Arf correct this is stupid... |
This fix #1174 does not help if we remove unnecessary inventory units
You could see why, here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L332-L338
UnitOfWork marks orphan entities to be removed before "onFlush" event.
And after https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/EventListener/OrderItemInventoryListener.php#L62 we need to re-commit entity to remove orphans.