Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [construct]

The tag has no usage guidance.

0
votes
2answers
27 views

Error on constructor of a class that extends \Magento\CatalogRule\Model\Rule

Im trying to do a model that extends \Magento\CatalogRule\Model\Rule, but in the contructor the context is giving me a warning: Declaration of overridden method should be compatible with parent class....
1
vote
2answers
46 views

How to pass custom parameters to parent construct?

I have extended \Magento\Sales\Controller\Adminhtml\Order to Custom class like below,but not able pass one more parameter($httpClientFactory) to this construct level. How to pass custom parameters($...
0
votes
0answers
37 views

Override __construct Magento\Catalog\Model\Product

I have overrided the Magento\Catalog\Model\Product. When I create a new function, I can access it with $this->_currentProduct->myNewFunction() in my code. But, in my new function, I need to ...
0
votes
1answer
48 views

How many types of Injection methods does Magento 2 support?

What types of Injection methods does Magento 2 support? I am aware about, Constructor Injection - consider as a Injection. Method Injection - consider as a Injection. BUT And Interface and Model ...
0
votes
2answers
31 views

How to replace direct use of Object Manager?

in the success.phtml file I currently have a direct use of the object manager, which I am now reading is not best practice. I was wondering how to make a constructor to replace the following code in ...
0
votes
1answer
28 views

Is this the correct way to write a constructor that extends this other PHP file?

I am using Magento 2.2.6. The file I am extending is \Magento\UrlRewrite\Model\Storage\DbStorage. It has the following constructor: /** * DB Storage table name */ const TABLE_NAME = 'url_rewrite'; ...
2
votes
2answers
30 views

Extends constructor

I have a class that extends \Magento\Customer\Block\Account\Dashboard\Info and I want to extend its constructor to get customer session, but how do I extend constructor? PhpStorm is highlighting my ...
0
votes
1answer
56 views

Magento 2 Loading customer through block error

I'm trying to use Magento best practices by not using Object manager, and instead loading what I need through my blocks. I've got this code in my newsletter.php block file: protected $...
2
votes
1answer
101 views

Difference between declare class in : “__construct” and in the top of file with “use” [duplicate]

Anyone have idea about declare class in __construct and declare class in top of file with use. Exemple: use Magento\Store\Model\StoreManagerInterface; and public function __construct( \...
2
votes
0answers
16 views

Magento 2.2.4 - unable to print messages. - New Theme

I have a Module which processes a Post action, and then redirects. for example i am trying to overwrite - Magento\Checkout\Controller\Cart\Add I have used my construct function and my method as ...
6
votes
3answers
508 views

Magento 2.2.5 : Cant go to execute() in Controller

I'm doing a simple CRUD custom module after this module C:\xampp\htdocs\magento\vendor\magento\module-cms\Controller\Adminhtml\Page\Save.php and I have a controller to save/create/add the "students" ...
0
votes
1answer
124 views

Override construct function in child class magento2

I want override a model class, for this I have made entry in di.xml and created a respective file on my custom module. My file is calling but now here apart from modify other functions I also need to ...
0
votes
1answer
63 views

Datetime Error on Newsletter Template

Steps to reproduce Go to Admin->Marketing->Newsletter Template Select Queue Newsletter from right dropdown Select a Queue Date Start and try to save it Expected Result Saved Actual result ...
1
vote
2answers
33 views

Magento2 :Change the object maganer to constructor

Can anyone help me how to change the object manager to a constructor in magento2: $om = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $om->get('Magento\...
0
votes
1answer
409 views

Argument passed to __construct() must be an instance of \Helper\Data

I get this error Argument 2 passed to [VENDOR][MODULE]\Controller\Index\Index::__construct() must be an instance of [VENDOR][MODULE]\Helper\Data this is my controller namespace [VENDOR]\[MODULE]\...
1
vote
0answers
344 views

“Fatal error: Uncaught TypeError: Argument 1 passed to […]::__construct() must be an instance of […]” after (re-)compile

So I've inherited this weirdly behaving (and horribly tinkered) shop containing some external product and customer import scripts. One of these scripts ('importcustomer_fields.php', located in the ...
0
votes
3answers
33 views

Controller not executing if changing constructor parameters

I have a Controller class as follow : class Delete extends \Magento\Framework\App\Action\Action { protected $cache; protected $cacheManager; public function __construct( \Magento\...
1
vote
1answer
1k views

Missed required argument request in parent::__construct call

I'm working on a Magento module for the past month, and everything works great on my local machine. Then I decided to release the module as a beta and test it online in a newly installed store, and ...
10
votes
3answers
2k views

XML Parsing Errors

I believe I have a syntax error or something? I'm confident it's either something to do with xml or syntax. Everything appears to be in order when i look into the file. This error is dealing with the ...
2
votes
1answer
210 views

Magento 2 model error after updating on 2.2 verison

I have a CRUD module created on magento 2.1.6 version which was working ok untill i updated magento to version 2.2.1 Now when i compile my code i receive the following err: namespace\module\Model\...
5
votes
3answers
5k views

magento2 Uncaught ArgumentCountError: Too few arguments to function

I am getting "Uncaught ArgumentCountError: Too few arguments to function on parent::__construct($context); Index.php <?php namespace MyTheme\Theme\Controller\Index; use Magento\Framework\App\...
1
vote
1answer
68 views

How to Override Construct function of Magento without violating "

I created a class with the construction: public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, array $data = [] ) { parent::__construct($...
3
votes
1answer
556 views

Does arguments order in constructor matters?

I've noticed strange situation while creating class contructor (__construct). Here is my code: public function __construct( \Magento\Framework\Model\Context $context, \Magento\...
0
votes
1answer
251 views

Using construct instead of object manager

I'm running into an error while converting below code that uses object manager to injecting within construct instead. In this example i have this code: $objectManager->create('Magento\...