Description
Preconditions
- Magento 2.4-develop
Steps to reproduce
I spot the issue during placing order with two different community modules installed. In short, during placing order the customer object is subscribed by custom code which utilizes newsletter module, then customer object is saved a couple times, and it results with subscribing him, unsubscribing and subscribing again.
It is a bit complicated to prepare such environment and to reproduce it so I prepared short steps which show incorrect framework behavior.
-
Load customer object using repository and check his subscription status:
$customer = $customerRepository->getById($customerId);
$extensionAttributes = $customer->getExtensionAttributes();
var_dump($extensionAttributes->getIsSubscribed()); // returns false -
Subscribe customer to newsletter:
$subscriber = $subscriberFactory->create();
$subscriber->subscribeCustomerById($customerId); -
Check subscription status again:
$customer = $customerRepository->getById($customerId);
$extensionAttributes = $customer->getExtensionAttributes();
var_dump($extensionAttributes->getIsSubscribed()); // still returns false
Expected result
- getIsSubscribed returns true when runs after subscribing customer
Actual result
- getIsSubscribed returns false
Metadata
Metadata
Assignees
Labels
Type
Projects
Status