0

this is my controller

<?php

namespace Prevaj\Orderswatches\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action {


    protected $_pageFactory;

    /**
     * Undocumented function
     *
     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\View\Result\PageFactory $pageFactory
     * @return void
     */
    public function __contruct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $pageFactory
    ){
        $this->_pageFactory = $pageFactory;
        return parent::__construct($context);
    }

    public function execute(){
        return $this->_pageFactory->create();
    }
}

this is the error im facing

Error: Call to a member function create() on null in /var/www/island.importers/app/code/Prevaj/Orderswatches/Controller/Index/Index.php:26 Stack trace: #0 /var/www/island.importers/vendor/magento/framework/Interception/Interceptor.php(58): Prevaj\Orderswatches\Controller\Index\Index->execute() #1 /var/www/island.importers/vendor/magento/framework/Interception/Interceptor.php(138): Prevaj\Orderswatches\Controller\Index\Index\Interceptor->___callParent() #2 /var/www/island.importers/vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php(51): Prevaj\Orderswatches\Controller\Index\Index\Interceptor->Magento\Framework\Interception{closure}() #3 /var/www/island.importers/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute() #4 /var/www/island.importers/vendor/magento/framework/Interception/Interceptor.php(153): Prevaj\Orderswatches\Controller\Index\Index\Interceptor->Magento\Framework\Interception{closure}() #5 /var/www/island.importers/generated/code/Prevaj/Orderswatches/Controller/Index/Index/Interceptor.php(39):

1 Answer 1

0

You omitted a letter in the function name:

public function __contruct(

Correct would be:

public function __construct(
2
  • This is a silly mistake i feel ashamed. Ty for helping Commented Jun 15, 2021 at 20:25
  • No problem, mate :D Anyway Commented Jun 15, 2021 at 20:26

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.