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):

asked Jun 15, 2021 at 16:50

1 Answer 1

0

You omitted a letter in the function name:

public function __contruct(

Correct would be:

public function __construct(
answered Jun 15, 2021 at 20:23
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.