I would like to override a template but only for a specific language (ar_SA)

The template I want to override is: Magento_Catalog/templates/product/list.phtml

I have tried putting it in the following locations but it didn't work for any of them:

<VENDOR>/<THEME NAME>/i18n/Magento_Catalog/templates/product/list.phtml

<VENDOR>/<THEME NAME>/i18n/ar_SA/Magento_Catalog/templates/product/list.phtml

<VENDOR>/<THEME NAME>/Magento_Catalog/i18n/templates/product/list.phtml

<VENDOR>/<THEME NAME>/Magento_Catalog/i18n/ar_SA/templates/product/list.phtml

<VENDOR>/<THEME NAME>/web/i18n/ar_SA/Magento_Catalog/templates/product/list.phtml

Any other suggestions or possibilities?

(My Magento version is 2.2.6)

  • May I ask what you try to achieve? This sounds to me like there might be an easier solution :-) – Fabian Blechschmidt Sep 26 at 12:54
  • @Fabian In English, the products lists pages flow from left to right. But in Arabic they should be from right to left. This is specially important when the last row is not filled up. I tried fixing it using CSS alone, but apparently, I will need to edit the template itself – Hassan Al-Jeshi Sep 26 at 13:25
  • 1
    Oh wow. I'm a backend guy, so no clue about frontend, but I would have guessed (no offense here!) that there is a html structure which can do both. But I totally understand that changing HTML depending on language make things easier :-) Good luck! – Fabian Blechschmidt Sep 26 at 14:01
up vote 6 down vote accepted

Create a child theme which inherits from your main theme. Add the template you want to override to your child theme.

See dev docs on Theme Inheritance.

Change theme for your ar_SA store view to the child theme you created.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.