You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have $relatedItem property in OrderItem class (https://github.com/shopsys/shopsys/blob/13.0/project-base/app/src/Model/Order/Item/OrderItem.php#L50) but it is basically not used. It is just set when creating a new order item of type coupon (which is actually an order item of type OrderItem::TYPE_PRODUCT at the moment while it deserves its own type, but we all know that 🙂). The getters are then never used if I am not mistaken.
I have two suggestions for how to improve the current implementation:
$relatedItem should be rather implemented as one-to-many relation (there might be more related items eg. when selecting a collection of services for a product). Something like this is better for a wider scale of use-cases IMHO:
We should really use the relation when we approach the related items (on the storefront, in the mail, etc.) - at the moment, we just iterate through the items and rely on the fact the related items are created right after their "parent" item - ie. we rely on the following: parentItem->getId() + 1 === $relatedItem->getId(). If we messed up the ids, the output would be broken. Instead, I suggest iterating just the PRODUCT_TYPE items and under them, iterating through their relatedItems to display the related coupons, services, or whatever the related items might be on the particular implementation.
Describe the bug
We have
$relatedItem
property inOrderItem
class (https://github.com/shopsys/shopsys/blob/13.0/project-base/app/src/Model/Order/Item/OrderItem.php#L50) but it is basically not used. It is just set when creating a new order item of typecoupon
(which is actually an order item of typeOrderItem::TYPE_PRODUCT
at the moment while it deserves its own type, but we all know that 🙂). The getters are then never used if I am not mistaken.I have two suggestions for how to improve the current implementation:
$relatedItem
should be rather implemented as one-to-many relation (there might be more related items eg. when selecting a collection of services for a product). Something like this is better for a wider scale of use-cases IMHO:parentItem->getId() + 1 === $relatedItem->getId()
. If we messed up the ids, the output would be broken. Instead, I suggest iterating just thePRODUCT_TYPE
items and under them, iterating through theirrelatedItems
to display the related coupons, services, or whatever the related items might be on the particular implementation.OrderItem
that represents the discount/coupon. Sad enough, there are two other issues (PromoCodes and OrderRounding are OrderItems with type product #1390 and Promo code is custom instance of OrderItem #1263) and one pull request (Order item has new typediscount
#1563) for thisThe text was updated successfully, but these errors were encountered: