3

I'm trying to override the

magento/module_customer/view/frontend/templates/account/dashboard/info.phtml

This page:

enter image description here

My code for layout in

view/frontend/layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance dc" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="dashboard.info">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">vendor_notifications::account/dashboard/info.phtml"</argument>
        </action>
    </referenceBlock>
</page>

In /templates/account/dashboard/ I have created the info.phtml

I have executed setup:di:compile and cache clean, but it did not work, what I'm doing wrong ?

I have followed this tutorial:

3 Answers 3

1

app/code/SR/MagentoCommunity/view/frontend/layout/customer_account_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_account_dashboard_info" template="SR_MagentoCommunity::account/dashboard/info.phtml"/>
    </body>
</page>

Also make sure, your module load after Magento_Customer module. For that you need to add sequence in module.xml.

Ex:

app/code/SR/MagentoCommunity/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="SR_MagentoCommunity" setup_version="2.0.2">
        <sequence>
            <module name="Magento_Customer"/>
        </sequence>
    </module>
</config>
2
  • how can i change the sequence ? Mar 13, 2019 at 15:17
  • Check updated answer. Dont forget to run 'setup:upgrade' command
    – Sohel Rana
    Mar 13, 2019 at 15:32
1

Here is another method you can override this way.

GO to your applied theme and create override

Magento_Customer/templates/account/dashboard/info.phtml

0

The name of your referenceBlock is not correct.

The name must me be the same as in the vendor folder. If you go to the customer_account_index.xml file you will find that the name of the block is:

            <block class="Magento\Customer\Block\Account\Dashboard\Info" name="customer_account_dashboard_info" as="info" template="Magento_Customer::account/dashboard/info.phtml" cacheable="false"/>

Use this name instead of dashboard.info

Youre file name needs to be the same as the file of Magento: customer_account_index.xml

2
  • The reference block need be: customer_account_dashboard_info ? Mar 13, 2019 at 15:01
  • Yes that's correct so your line is: <referenceBlock name="customer_account_dashboard_info"> Mar 13, 2019 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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