0

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.

In

customer/account/create/

I have couple of extra fields and when user fill those up I will assign that user to website 2 and storeview of 6.

Users will receive related emails based on the website and storeview and everything works fine, except Success Email Template for signup for newsletter. enter image description here

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.

Also customer will receive correct email template after registration if they subscribe when they are logged in their account. enter image description here

So it is not an issue with admin config.

I looked into module-newsletter files and here

vendor/magento/module-newsletter/Model/Subscriber.php

on method

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.