Wishlists that aren't using multiple wishlists don't get their wishlist items merged as an anon user if their auth account already has an active wishlist

Created on 26 September 2024, 3 months ago

Problem/Motivation

So merging wishlists doesn't work if your auth account already has an active wishlist with items in it. This due to the fact that the $duplicate_wishlist_item variable on the WishlistManager->Merge() method doesn't change the wishlist_id of the wishlist_item. There is code that sets the $duplicated_wishlist_item to the $target_wishlist, but in the database, after this has completed, the merged in wishlist_item still references the anon wish list ID and thus isn't merged into the logged in users existing wishlist.

Steps to reproduce

As an auth user, add a product to a wishlist. Then log out and become an anon.
As the anon, add a different product to a wishlist and then log in as your auth user.
Observe that the product you added to your wishlist as an anon hasn't made it over to your existing auth wishlist.

Proposed resolution

Adding this line of code $duplicate_wishlist_item->set('wishlist_id', $target->id()); to the merge function solves the issue as the wishlist item now correctly references the auth wishlist.

Will add an MR shortly

🐛 Bug report
Status

Active

Component

Code

Created by

🇬🇧United Kingdom ChristianSanders

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024