Description
Preconditions (*)
- Magento 2.3.6 or lower (maybe greater)
Steps to reproduce (*)
Setup Multiple Stores/websites in Magento
Create 2 different Stock Alert Email Templates for each store (Marketing - Communications - Email Templates - Add New Template)
Enable Product Alerts and Apply the newly created templates for each Store
Stores - Configuration - Catalog - Catalog - Product Alerts - Stock Alert Email Template - Set the new template created for new Store view scope , "Allow Alert When Product Comes Back in Stock" - Yes
Default Scope: Product Alerts Run Settings - Give the Start time and Save Configuration
Change the Scope of Store View to another Store view and apply other newly created template and save the configuration
Reindex and clear cache
Admin - Add a new Product - Set the Product to Out Of Stock and Save
Front-end - New Store website (for ex: France website) - Sign in as customer - Product Details page - Click on "Notify me when this product is in stock"
Open the same Product in different Store (for ex: Germany website) - Sign in as same customer - Product Details page - Click on "Notify me when this product is in stock"
Admin - Edit the same product and Set the stock status to "In Stock" and Save
Run the Cron > php bin/magento cron:run
Verify emails of both the Stores
Expected result (*)
- Each email should have the right template
Actual result (*)
- Only the first processed store template is serving
Workaround
I found out that it's caused by \Magento\Framework\View\Element\Template\File\Resolver::getTemplateFileName
In this case, the $key to store the template and avoid multiple times the same process to run is the concatenation of the template identifier with params given by \Magento\Framework\View\Element\Template
.
In this case i recommend in \Magento\Framework\View\Element\Template::getTemplateFile
to add in parameters the store id in parameters by this way :
$params = ['module' => $this->getModuleName()];
could be
$params = [
'module' => $this->getModuleName(),
'store_id' => $this->_storeManager->getStore()->getId()
];
or
$store = $this->_storeManager->getStore();
$params = [
'module' => $this->getModuleName(),
'store_id' => $store ? $store->getId() : \Magento\Store\Model\Store::DEFAULT_STORE_ID
];
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status