Skip to content

Newsletter subscription does not set the correct store_id if already subscribed. #19131

@bbmxxc

Description

@bbmxxc

Preconditions (*)

  1. latest Magento Version 2.3-dev
  2. Have at least two stores ( A and B)

Steps to reproduce (*)

  1. Register a user in A
  2. Subscribe to Newsletter in A
  3. Switch to Store B
  4. Subscribe to Newsletter again

Expected result (*)

  1. When in store B, Subscriber::loadByEmail() should work
    2. SELECT store_id, customer_id FROM newsletter_subscriber should look like this:
+----------+-------------+
| store_id | customer_id |
+----------+-------------+
|        1 |           1 |
|        2 |           1 |

Actual result (*)

  1. When in store B, loadByEmail() (or loadById() ) cant find the subscriber since
  2. SELECT store_id, customer_id FROM newsletter_subscriber looks like this:
+----------+-------------+
| store_id | customer_id |
+----------+-------------+
|        1 |           1 |
|        1 |           1 |

What i think where the error is

In app/code/Magento/Newsletter/Model/Subscriber.php starting on line 468:
If the subscriber already exists with this email, the new entry gets the $customer->getStoreId()
not the $this->_storeManager->getStore()->getId()

If this is the intended behavior then loadByEmail() or loadByCustomerId() should be store_id agnostic.

Cheers!
Ben

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions