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.


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" />

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


Solution : backslash and ran setup:upgrade

change from

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


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

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.