Magento 2 – Override cacheable=”false” with Custom Theme

full-page-cachelayoutmagento2

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?

Best Answer

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
Related Topic