1

I'm trying to extend Magento\Customer\Block\Account\Dashboard\Info.php file. I created a module, where I have my custom block, Info.php. I want to display the telephone number of the customer after.

<?php

namespace Portail\Customer\Block\Account\Dashboard;

class Info extends Magento\Customer\Block\Account\Dashboard\Info
{
    public function testTxt(){
        return 'bonjour';
    }
}

I have added a di.xml in etc/

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Customer\Block\Account\Dashboard\Info" type="Portail\Customer\Block\Account\Dashboard\Info" />
</config>

But I have this error : Method invalid Magento\Customer\Block\Account\Dashboard\Info::testTxt

1 Answer 1

1

Solution : backslash and ran setup:upgrade

change from

class Info extends Magento\Customer\Block\Account\Dashboard\Info

to

class Info extends \Magento\Customer\Block\Account\Dashboard\Info

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.