Skip to content

[Core] Fix inventory unit orphan removement#1186

Merged
pjedrzejewski merged 1 commit intoSylius:masterfrom
fullpipe:master
Mar 13, 2014
Merged

[Core] Fix inventory unit orphan removement#1186
pjedrzejewski merged 1 commit intoSylius:masterfrom
fullpipe:master

Conversation

@fullpipe
Copy link
Copy Markdown
Contributor

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.

@stloyd stloyd added the Bug Fix label Mar 11, 2014
@stloyd stloyd added this to the 1.0.0-BETA1 milestone Mar 11, 2014
@pjedrzejewski
Copy link
Copy Markdown
Contributor

Thanks for the patch @fullpipe, what do you think @winzou?

@kayue
Copy link
Copy Markdown
Contributor

kayue commented Mar 12, 2014

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.

@pjedrzejewski
Copy link
Copy Markdown
Contributor

@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. :/

@winzou
Copy link
Copy Markdown
Contributor

winzou commented Mar 13, 2014

Will try all this today, that's crazy how I missed it...

@kayue
Copy link
Copy Markdown
Contributor

kayue commented Mar 13, 2014

@pjedrzejewski This fix works for me :)

Thanks @fullpipe

@winzou
Copy link
Copy Markdown
Contributor

winzou commented Mar 13, 2014

It's all good but we miss inventory units deletion when clearing cart.
Can't see why, as we have a cascade all on the relation OrderItem > InventoryUnits and on Order > OrderItem. In the case of order item deletion only (remove 1 item from the cart), inventory units are well deleted though.
@fullpipe @kayue idea?

@kayue
Copy link
Copy Markdown
Contributor

kayue commented Mar 13, 2014

@winzou Sorry I can't follow you. When do we "clearing cart"? How to reproduce this?

@winzou
Copy link
Copy Markdown
Contributor

winzou commented Mar 13, 2014

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.

pjedrzejewski pushed a commit that referenced this pull request Mar 13, 2014
[Core] Fix inventory unit orphan removement
@pjedrzejewski pjedrzejewski merged commit 9c79bb8 into Sylius:master Mar 13, 2014
@pjedrzejewski
Copy link
Copy Markdown
Contributor

@winzou Let's tackle this in separate PR, as this current issue is much more annoying. Thank you @fullpipe & @kayue for testing. :)

@fullpipe
Copy link
Copy Markdown
Contributor Author

I think I found the problem.
"clear cart" does not clear inventory units because Order is softdeletable
And $this->cartManager->remove($event->getCart()); does not trigger cascade-remove

@winzou
Copy link
Copy Markdown
Contributor

winzou commented Mar 13, 2014

Arf correct this is stupid...
@pjedrzejewski we really need a service that handles cart operations (create, delete, add item, remove item, etc.). No operation on cart are allowed outside of this service. So that we ensure that every events are trigger in every case, with the right parameter and information on which item is added, etc. I'll try to manage this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants