Fix newsletter subscription multiple callings #18480
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When working with newsletter module I found when customers update their subscription, Magento did it two and even three times (I mean by counting calling the same method in Subscribe model). My PR fixes that, so it may improve performance and stability.
Manual testing scenarios
1. When customers manages his subscription status from private office
1.1. Login as customer
1.2. Go to private office and click Edit on Newsletters block
1.3. Update customer subscription (if customer was subscribed then unsubscribe, otherwise subscribe)
Expected result:
Subscription status will be updated 1 time
Actual result:
Subscriber method "_updateCustomerSubscription" was called 3 times:
2. When admin manages subscriber status from backend
2.1. Go to Customers and edit customer
2.2. Update customer subscription (if customer was subscribed then unsubscribe, otherwise subscribe)
Expected result:
Subscription status will be updated 1 time
Actual result:
Subscriber method "_updateCustomerSubscription" was called 2 times:
Contribution checklist