Search code examples
shopwareshopware6shopware6-app

Shopware cart.updated_at changes on login


As a logged customer , I've added some products in my cart (new entry in cart table is inserted with all my data)

What I observed: Every time I login to my account, the cart.updated_at date field is updated even if I'm not changing anything to my cart.

Is this a bug? If not, why does that field need to be updated every time we login?

Tested on shopware 6.4.14.0 and 6.4.11.0

The field is updated on every action I take as a logged user


Solution

  • There's a CleanupCartTask that removes abandoned carts that haven't been updated for a certain amount of days (120 by default, configured in shopware.yml). For this task alone the date needs to be updated, otherwise abandoned carts couldn't be identified.

    Furthermore the cart needs to be recalculated because rules that influence prices may have changed or been added. This alone doesn't necessitate persisting the cart, as prior and current active rules could be compared, but in conjunction with the aforementioned cleanup task, it's reasonable to persist the recalculated cart anyways for safekeeping.