Newsletter subscriptions status not isolated between multi stores #10014
Labels
bug report
Component: Customer
Fixed in 2.2.x
The issue has been fixed in 2.2 release line
Fixed in 2.3.x
The issue has been fixed in 2.3 release line
Issue: Clear Description
Gate 2 Passed. Manual verification of the issue description passed
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Issue: Format is valid
Gate 1 Passed. Automatic verification of issue format passed
Issue: Ready for Work
Gate 4. Acknowledged. Issue is added to backlog and ready for development
Reproduced on 2.1.x
The issue has been reproduced on latest 2.1 release
Reproduced on 2.2.x
The issue has been reproduced on latest 2.2 release
Reproduced on 2.3.x
The issue has been reproduced on latest 2.3 release
When a customer with the same email address has an account on different multi stores in the same Magento installation, changes to the newsletter subscription in one account affect the other.
Preconditions
Steps to reproduce
Expected result
Actual Result
Extra info
When looking in the newsletter_subscriber table, instead of there being one record for each customer per store, there's one global record. When customer 1 in store A updates, the store_id in newsletter subscriber is updated to store A's ID. When customer 2 in store B updates, the store_id in newsletter_subscriber is updated to store B's ID.
Tracing the code out, I think the problem is in Magento_Newsletter\Model\ResourceModel\Subscriber.php, specifically the loadByCustomerData function.
Here's the function:
It basically uses the customerId as the lookup key but then falls back to the customerEmail if nothing is found. This creates the unintended consequence where updates in one store show in the other. A suggested fix would be to either only use the customerId or add an additional field to the select that matches the store_id of the customer, something like
The text was updated successfully, but these errors were encountered: