Skip to content

Template file retrieving should be store scoped #33519

Open
@alexmtch

Description

@alexmtch

Preconditions (*)

  1. 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 (*)

  1. Each email should have the right template

Actual result (*)

  1. 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

No one assigned

    Labels

    Area: CatalogComponent: EmailIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.3.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Pull Request In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions