Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Order
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Feb 2017 at 17:46 UTC
Updated:
25 Apr 2018 at 13:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mglamanWe treat order items as an embedded entity. We do this in the refresh process - order items are refreshed when the order is handled. So any action on order items should happen when the order is also saved.
If an order item is created the order itself will soon be saved, as it needs its price recalculated.
I wonder if
>addItemon the Order class should at least populate the order ID. Maybe that would be the compromise?Comment #3
lisastreeter commentedI've modified the CartManager class to set the order id for an item when the item is added to the cart.
Comment #4
lisastreeter commentedSimpler, less disruptive approach.
Comment #5
mglamanAt first review I thought this should go in
addEntity. But the AddToCartForm actually invokesaddOrderItemsince it is an order item form.This makes sense to me, then.
Comment #6
josephdpurcell commentedI looked at the code and it looks correct: it adds the order id to the order item always only when its a new item added to the cart. And there is a test. And the patch applies. Setting RTBC.
Comment #7
mglamanKicking back to Needs Review. I should have commented this before, but I think we really need feedback from steveoliver and the commerce_stock folk. I believe they need this most, and we need to validate this approach works for them.
Comment #8
olafkarsten commented#4 looks good. It solves the issue for stock. Thanks!
Comment #9
olafkarsten commentedSorry, need to correct myself. The original idea for commerce_stock was to act on OrderEvents::ORDER_ITEM_INSERT. That would require the backreference to the parent order is always there before it gets inserted. I don't think we will resolve this and I don't think its necessary for stock. It's just the wrong event for commerce_stock to act on. Note: this is not a critical issue for stock. The "work around" mentioned in the issue summary is in fact the correct approach.
Comment #11
bojanz commentedThanks!
Comment #13
joachim commentedIs this code in Order now redundant in normal operations?
It should ideally stay though, as Commerce Migrate relies on it.