Questions tagged [dependency-injection]
Denotes questions regarding Magento 2 Dependency injection
227 questions
0 votes
1 answer
43 views
Magento 2 - Model does not extend \Magento\Framework\DataObject
I'm trying to view a grid in database but I'm stuck on this error: Es100\ProductNotifier\Model\ResourceModel\Subscription\Grid\SubscriptionModel does not extend \Magento\Framework\DataObject ...
0 votes
1 answer
79 views
Minimal Dependency Injection Preference Example
I am trying to change the logic in my Elasticsearch engine from "and" logic to "or" logic following the advise of the second answer in this question How do I change Magento 2 ...
0 votes
1 answer
260 views
How to remove the Deprecated property of __construct from Abstract Class using overriding or any other way
Error main.ERROR: Deprecated Functionality: Creation of dynamic property Magiccart\Magicproduct\Controller\Adminhtml\Product\Index\Interceptor::$_resultRedirectFactory is deprecated in vendor/...
1 vote
2 answers
957 views
__construct(...) and "automatic" dependency injection
I have recently been asked to help maintain a Magento module, and while I generally understand what DI is and why we want to use it, I was a bit confused by the 'automatic' side of things in Magento. ...
0 votes
2 answers
146 views
Why doesn't work Dependency Injection from example?
I have tried to create DI like there (Data and DependentClass) but it doesn't working for me: "ArgumentCountError: Too few arguments to function DependentClass::__construct(), 0 passed...." ...
2 votes
1 answer
3k views
How to override Magento 2 graphql resolver with custom plugin
Im trying to override the resolver by using a plugin in Magento 2 to change text. vendor/magento/module-quote/Model/CouponManagement.php - I need to change this class ApplyCouponToCart implements ...
0 votes
1 answer
54 views
Blank page when trying use direct injection with ProductRepositoryInterface class
I am fairly new to Magento and following a tutorial on Udemy to learn how to develop on Magento 2. I am attempting to overwrite the ProductRepositoryInterface, however whenever I add the preference ...
0 votes
0 answers
219 views
Custom model save data processor DI/Reflection only working once?
I'm working on a simple FAQ widget module for a client and I seem to have run into something quite strange with the DI/Reflection cache. My problem is with the Save controller action which uses a ...