I have a shop with two websites and storeview. let's say
Website = 1 & 2
Storeview = 5 & 6
The storeview 6 is not visible directly and only registered customers will access it when they login. Customers use an option to register for website 2 and access storeview 6 on website 1 with storeview of 5.
I have couple of extra fields and when user fill those up I will assign that user to website 2 and storeview of 6.
the success Email template is always sent from website1 storeview5. I checked the admin config and templates are set correctly on store configuration->customer->newsletter.
So it is not an issue with admin config.
I looked into module-newsletter files and here
public function sendConfirmationSuccessEmail()
seems to be the one that sets the storeId like this
$this->_transportBuilder->setTemplateIdentifier( $this->_scopeConfig->getValue( self::XML_PATH_SUCCESS_EMAIL_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) )->setTemplateOptions( [ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, //'store' => $this->_storeManager->getStore()->getId(), 'store' => 6, ] )->setTemplateVars( ['subscriber' => $this] )->setFrom( $this->_scopeConfig->getValue( self::XML_PATH_SUCCESS_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) )->addTo( $this->getEmail(), $this->getName() );
for testing purpose I manually commented out the
'store' => $this->_storeManager->getStore()->getId(),
and set the id to 6. But it is not working. When I register I still gets templates of website1 and storeview of 5.
btw the $customer->getStoreId() has correct id of my desire site(2) & storeview(6). So it is not an issue with websiteId/StoreId of $customer.
Anyone has any idea why this happens? is that id set somewhere else?