The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [construct]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
35 views

Error occurred when creating object

I have a plugin with constructor <?php namespace Vendor\Contact\Plugin\Controller\Index; use \Zend_Validate; use Magento\Contact\Controller\Index\Post; use Magento\Framework\App\Request\Http; use ...
4
votes
1answer
41 views

Magento 2 What is the fastest way to get construction changes?

Whenever I made any changes on the construction method, I need to do bin/magento setup:di:compile to get any changes on my code. It was wasting my time, how can I get any changes faster than have to ...
0
votes
1answer
34 views

Magento 2: How we can add construct into overridden class

If There are no parent::__construct from parent class then How we can add construct into overridden class?
0
votes
1answer
32 views

What's the logic of inherited constructor order parameters

I have this module class namespace VendorName\Module\Block\Magento\Framework\Pricing; use Magento\Framework\Pricing\Amount\AmountInterface; use Magento\Framework\Pricing\Price\PriceInterface; use ...
0
votes
2answers
49 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
89 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
134 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 ...
1
vote
2answers
62 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
32 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
35 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
38 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 ...
2
votes
1answer
105 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
17 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
755 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
168 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
71 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
36 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
611 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
405 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
46 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
2k 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
3k 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
270 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
6k 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
76 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
648 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
339 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\...