Skip to content

Magento 2: Controller Invalid return type for Account Controller

Just wrote the following controller:

namespace MySiteMyCustomModuleControllerDashboard;

use MagentoCustomerControllerAccountInterface;
use MagentoFrameworkAppActionHttpGetActionInterface as HttpGetActionInterface;
use MagentoFrameworkViewResultPageFactory;

class Index implements AccountInterface, HttpGetActionInterface
{
    /**
     * @var PageFactory
     */
    protected $resultPageFactory;

    /**
     * @param PageFactory $resultPageFactory
     */
    public function __construct(
        PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;
    }

    /**
     * Default customer account page
     *
     * @return MagentoFrameworkViewResultPage
     */
    public function execute()
    {
    
        return $this->resultPageFactory->create();
    }
}

However, when trying to get results,

also di.xml

enter image description here

go to the needed route http://mysite.lo/customer/dashboard and get the following issue:

1 exception(s):
Exception #0 (InvalidArgumentException): Invalid return type

Exception #0 (InvalidArgumentException): Invalid return type

#1 MagentoFrameworkAppBootstrap->run() called at [pub/index.php:31]

and even debug cannot log in to method execute.

Does anyone face this issue?