having single row per LineItem with quantity > 1 in cart view

Hi folks, 

please advice best practice to achieve to have a single row per LineItem(s) in cart view if the quantity of LineItem is > 1.

Right now the cart is showing only one row per LineItem->id, which usually is good practice!

Due to the reason as we do enrich LineItems with specific custom payload information (customized product-design), we want the customer to be able to view, update, remove, edit, etc… each LineItem even if the LineItem->id is the same.

Please give advice.

Thx in advance and kind regards,


Addtocart with stackable=false

1 Like

@oliverriske schrieb:

Addtocart with stackable=false

thanks for your reply, but this will NOT work. will result in “LineItemNotStackableException”.

The way i try to proceed now is as follows: 

from here: https://github.com/shopware/platform/issues/151 => 

    • If you want to add a product as a single row, simply add generate a unqiue key and provide it as line item key.

if as i understand correct than: referencedId is the true relationship <=> productId, we simple have to create a new and unique LineItem->key.

I will do so, and report back.

 Did not expect it to be that easy: id of LineItem has to be a random Uuid to appear as single row. The only important thing is that the referenceId references the correct product. 

 $lineItem = new LineItem(Uuid::randomHex(), "product", NULL, 1);
1 Like

Sorry yes forhot that you have to generate a uuid

Hey guys,

it can be even easier. Just subscribe to the BeforeLineItemAddedEvent and:

        if (!$event->getLineItem()->isStackable()) {

Does the exact same as @develissimo stated. However, I think @develissimo wrote a entire new controller. Subscribing to the event is a little more elegant I think.

it works. super. thanks