0

I'm trying to override a Magento default xml layout file vendor/magento/module-review/view/frontend/layout/customer_account_index.xml

<referenceContainer name="content">
    <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="Magento_Review::customer/recent.phtml" after="customer_account_dashboard_address" cacheable="false"/>
</referenceContainer>

I need to change cacheable="false" to cacheable="true"

So I try to override the layout xml as I normally do, by creating a new folder like this in my own template,

app/design/frontend/my_vendor/my_theme/Magento_Review/layout/customer_account_index.xml

and I changed cacheable="true" as following,

<referenceContainer name="content">
    <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="Magento_Review::customer/recent1.phtml" after="customer_account_dashboard_address" cacheable="true"/>
</referenceContainer>

But this didn't work. The page loads both my own xml and xml from vendor folder, so now I have both cacheable="false" and cacheable="true" on the same layout.

But I need to remove cacheable="false", so full page cache can be used.

I have cleared cache.

Did I miss anything?

  • See here how to override a layout: devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/… – Marius Jan 17 '19 at 13:42
  • @Marius Thanks, I actually looked at this link. Can you see if my rewrite path is correct? app/design/frontend/my_vendor/my_theme/Magento_Review/layout/customer_account_index.xml – Magento Learner Jan 17 '19 at 13:58
  • 1
    it's not really the same. you are missing one 'override' folder. – Marius Jan 17 '19 at 15:02
  • wow, you saved my life. It was exactaly because my rewrite path was wrong. I missed actually two folders. You are welcome to post this into answer and I'll accept as the answer. Otherwise I'll write this as answer myself. Thanks for the help. – Magento Learner Jan 17 '19 at 16:01
1

You can find here the official docs about how to override a layout: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-override.html

To override a base layout you need your path to look like this:

<theme_dir>
  |__/<Namespace_Module>
    |__/layout
      |__/override
         |__/base
           |--<layout1>.xml
| improve this answer | |
  • Yes, the correct rewrite path for me should be, app/design/frontend/my_vendor/my_theme/Magento_Review/layout/override/base/customer_account_index.xml – Magento Learner Jan 17 '19 at 16:22
0

Run below commands and check.

rm -rf ./var/cache/*
rm -rf ./pub/static/*
php bin/magento setup:upgrade 
php bin/magento setup:static-content:deploy OR php bin/magento setup:static-content:deploy -f
| improve this answer | |
0

you can try below code

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <update handle="customer_account"/>
        <body>
            <referenceContainer name="content">
        <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="Magento_Review::customer/recent1.phtml" after="customer_account_dashboard_address" cacheable="true"/>
    </referenceContainer>
        </body>
    </page>
| improve this answer | |
  • Thanks, but the page still load both xml files. – Magento Learner Jan 17 '19 at 11:41
  • not working ? above method is correct method for cacheable="false" – Rakesh Donga Jan 17 '19 at 11:45
  • not working for me. It loads my xml with cacheable="true", so no problem about this. but the default xml from vendor is also being loaded, and it still has cacheable="false". – Magento Learner Jan 17 '19 at 11:47
  • My rewrite path for this xml file is correct right? app/design/frontend/my_vendor/my_theme/Magento_Review/layout/customer_account_index.xml – Magento Learner Jan 17 '19 at 11:59
  • file is right you can run below command after check it 1.rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/* 2.php bin/magento setup:upgrade 3.php bin/magento setup:di:compile 4.php bin/magento setup:static-content:deploy -f 5.php bin/magento cache:flush – Rakesh Donga Jan 17 '19 at 12:08

Your Answer

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

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