Questions tagged [di]

Denotes questions related to Dependency Injection in Magento 2.

Filter by
Sorted by
Tagged with
0
votes
2answers
31 views

What is the meaning of below code (DI injection of proxy)

Can someone explain me what does this code does, when we need this. di.xml <type name="Magento\Wishlist\Helper\Data"> <arguments> <argument name="...
0
votes
1answer
17 views

What does the meaning of below piece of code (DI)

I found this code in a di.xml file with the code below. can someone tell me what the piece of code means. <virtualType name="Magento\Downloadable\Pricing\Price\Pool" type="Magento\...
0
votes
1answer
192 views

Admin Grid wont show and getting "Request validation failed for action" error in debug

I was trying to create an admin grid in the adminhtml trying to learn how they function and work and I ran into an issue following this guide: Mageplaza. I've been trying to debug where the issue is ...
0
votes
2answers
34 views

Magento 2 - Can't override class - must be an instance of

I created a preference override for Magento\Quote\Model\Quote\Item\CartItemPersister in my own module. But I get this error in the browser developer console: Total: Type Error occurred when creating ...
0
votes
2answers
37 views

I get a blank page after adding $block->getLayout()->createBlock() to the Module?

I am trying to inject \Magento\Customer\Model\Session into the QuickOrder module. I want the page to show a different message when the user is not logged in. In the directory app/code/Magento/...
0
votes
0answers
45 views

Magento 2 override resource model collection not working

I want to override Magento Reports module and it's not working. here's my code : di.xml <preference for="Magento\Reports\Model\ResourceModel\Report\Collection" type="SZK\Shamsi\Model\...
0
votes
1answer
13 views

Error during compilation - Extra parameters passed to parent construct

During deployment when i run setup:di:compile i got error in one of my block, Extra parameters passed to parent construct: $data Guide me on this issue File name:index.php File location:app/code/...
0
votes
0answers
48 views

Custom Joins with Join Processor

I'm using Magento ver. 2.4.2 and try join two tables using Custom Joins According this example I use it this way di.xml: <virtualType name="Vendor\Module\Model\CollectionProcessor\...
0
votes
0answers
24 views

Magento 2 DI creates two instances of a class and can't control which is one is being injected

I'm quite new to Magento 2 (.4.2) and I'm debugging some strange issue I'm having. We're facing an issue that it's impossible to sort the search results by relevance and looking at the code and ...
0
votes
1answer
69 views

How to change the constructor parameter in magento2?

public function __construct( \Magento\Framework\Data\Collection\EntityFactoryInterface $entity, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\...
0
votes
2answers
122 views

Magento 2 - preference override not working for method sendConfirmationRequestEmail of module-newsletter

I try to override the method sendConfirmationRequestEmail from the module-newsletter Module in vendor\magento\module-newsletter\Model\Subscriber.php. Attempt: app\code\Company\Newsletter2Go\etc\di.xml ...
0
votes
1answer
44 views

Override Model from third party vendor in custom theme

I am trying to override a Model from a third Party vendor in a custom-theme. The original file was: /vendor/3rdpartyompany/3rdpartymodule/Model/Formatter/BaseImage.php I copied that file over to: /...
0
votes
1answer
65 views

Magento 2 - Product gallery magnifier not working after overriding Gallery class

My magnifier is not showing anymore IF THE PRODUCT HAS MULTIPLE IMAGES, after I have overriden the gallery class! I have enabled the magnifier in THEME\etc\view.xml: <?xml version="1.0"?&...
1
vote
2answers
318 views

Error during compilation in magento2 .3 Incompatible argument type: Required type:

Webkul\Marketplace\Model\Order\Pdf\Creditmemo Incompatible argument type: Required type: \Magento\Store\Model\App\Emulation. Actual type: \Magento\Framework\Locale\ResolverInterface; File: /var/www/...
0
votes
1answer
46 views

Error during compilation of Magento 2 Incompatible argument type : Required type:

Webkul\VendorPos\Model\ResourceModel\Orders\Grid\Collection Incompatible argument type: Required type: \Magento\Framework\App\Config\ScopeConfigInterface. Actual type: \Magento\Framework\DB\Adapter\...
0
votes
1answer
55 views

Adding a productAttribute handler in Magento 2.4

I'd like my Magento 2.4 module to be able to modify the output of one of the product attributes programatically. I see that the ability to create a handler for this purpose was added in Magento 2.3.4, ...
0
votes
2answers
157 views

How do I get an order collection in admin order view using the email address of the current order?

I am trying to build an order history table to display previous orders (order number/date/items ordered, etc) from a customer order in the admin order view (Magento\Sales\Block\Adminhtml\Order\View\...
0
votes
1answer
129 views

Plugin for Magento\Shipping\Model\Rate\Result not working

I am trying to disable the default sorting based on price, that is happening on shipping methods. I found that this is happening in sortRatesByPrice() vendor/magento/module-shipping/Model/Rate/Result....
0
votes
1answer
641 views

Search $block->getData('configProvider') in form.mini.phtml returns null after upgrade to 2.3.6

In 2.3.6, the following line was added to form.mini.phtml: $configProvider = $block->getData('configProvider'); Since the upgrade, this returns null and causes a fatal error due to this subsequent ...
0
votes
1answer
644 views

Is it possible to override a vendor module's di.xml file in Magento2?

So a module installed via composer lives in vendor/module, and I'd like to change its etc/di.xml from this: <virtualType name="customCategoryCollection" type="Magento\...
0
votes
1answer
566 views

Getting error Not registered handle cms_page_listing_data_source in Magento 2?

I have added some filter in Sales -> Order and for that add a di.xml file. di.xml file <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&...
1
vote
3answers
274 views

Magento 2 di.xml Parameter configuration inheritance explanation with example

I read about the Parameter configuration inheritance in Magento documentation but not able to understand the concept properly! https://devdocs.magento.com/guides/v2.4/extension-dev-guide/build/di-xml-...
1
vote
1answer
189 views

Why I'm receiving an error messages Class does not exist when running DI compile?

Why am I receiving error messages "Class does not exist" when running DI compile? I removed some modules using the node replace in my composer.json, as you can see below. "replace"...
1
vote
0answers
21 views

DI compilation error when referenced module is not installed

I have a module that integrates with other modules from other developers. These other modules may or may not be installed, it is different for each user. As an example, the MSG_InstantSearch module ...
1
vote
0answers
14 views

Is it possible to retrieve dependency injected arguments in another class?

Is it possible to retrieve dependency injected arguments in another class? For example, we have a class Vendor\Module\Block\Autocomplete. // app/code/Vendor/Module/Block/Autocomplete.php namespace ...
0
votes
1answer
424 views

Dependency Injection (di.xml) - (virtualType vs type) Magento 2 xsi:type='object'

Can someone please explain when you would use <type/> or <virtualType in your di.xml file? I want to make sure I understand it correctly.. At the moment, this is what I sort of think the ...
0
votes
2answers
167 views

Magento 2.3 - Error related to Amasty shopby while RUNNING setup di:compile

MiBPHP Fatal error: Declaration of Amasty\Shopby\Model\Source\Attribute\Extended::toOptionArray() must be compatible with Amasty\Shopby\Model\Source\Attribute::toOptionArray($boolean = 1) in /...
0
votes
2answers
109 views

Override Magento 2 Order Invoice PDF

I can not seem to override the Magento Invoice class. I've created a module, installed it, enabled it. I have the following in my di.xml file <?xml version="1.0"?> <config xmlns:xsi="http://...
1
vote
1answer
159 views

Not able to use virtualType as Action constructor argument

In short I seem unable to use a virtualType I created as an argument in my Action's contructor but everything works fine when using a concrete class instead. Index.php (my action): namespace Unit1\...
1
vote
1answer
792 views

What is the use of php bin/magento dev:di:info command?

With Magento 2.3, console command found which helps developers to find all the classes related to dependency injection. It seems that it shows dependency Injection classes from di.xml from all areas. ...
1
vote
1answer
465 views

Magento 2 Overide public static method of framwork class

I want to override public static function getCorrectFileName method of Magento\Framework\File\Uploader, I have check with Preference and Plugin but it is not working for me. Anyone have idea about ...
0
votes
0answers
79 views

aroundSavePaymentInformationAndPlaceOrder plugin not working in magento 2

etc/di.xml <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config....
1
vote
1answer
753 views

Magento 2 Injecting Object in $data array

I am trying to inject my custom object in constructor like this in di.xml <type name="Magento\CatalogSearch\Block\Advanced\Result"> <arguments> <argument name="data" xsi:...
10
votes
1answer
614 views

What is/means/does Magento\Framework\EntityManager\MetadataPool and Magento\Framework\EntityManager\Operation\ExtensionPool

There are new things we can see at Magento 2.3 in di.xml for service contracts. let's give an example:Magento_Cms module Like Magento\Framework\EntityManager\MetadataPool Magento\Framework\...
0
votes
1answer
132 views

Magento 2 Class CoinGate\Merchant does not exist

I have installed the CoinGage_Merchant module in Magento 2.3 setup but when I fire di:compile command it is showing below error. I set the generated folder permission 777 before compile command but ...
1
vote
1answer
39 views

Why avoiding ObjectManager can save us from multiple issues if Magento upgrade?

A new dependency injection framework will be used for the code. By avoiding ObjectManager in Magento 2, you won’t face multiple issues caused by the improvement. source:https://firebearstudio.com/blog/...
18
votes
6answers
6k views

Magento 2.3.3 Fails on magento setup:di:compile with an error mentioning InvoiceFlexFieldProcessorInterface

I have installed the new Magento 2.3.3 version. After I have run the command: php bin/magento setup:di:compile I have Faced the following error: PHP Fatal error: Interface 'Vertex\Tax\Model\...
1
vote
0answers
126 views

Di.xml error Cannot instantiate interface

I am trying to use the di.xml to pull a table from different module to populate a dropdown in the admin panel. When I write the XML code below it is throwing this error: PHP Fatal error: Uncaught ...
1
vote
0answers
53 views

Where are di.xml files merged?

My questions is pretty simple and straight forward. Somewhere in the code di.xml files are read and merged. Where is this happening?
1
vote
1answer
752 views

Magento 2: Override di.xml in custom theme

I have a module in vendor/company/module. I have created the following folder to override files. /vendor/theme/theme-frontend-default/Company_Module. I am able to override files in view folder but I ...
0
votes
3answers
143 views

Error while running di:compile command

Getting ReflectionException] Class PayPal\Api\PayoutSenderBatchHeader does not exist error while running php bin/magento setup:di:compile command
1
vote
1answer
54 views

Using composition in patches / install scripts

TL;DR: Is there a way to declare virtual types and different arguments in di.xml of a module and have that configuration be picked up when the module gets installed without calling bin/magento module:...
0
votes
1answer
473 views

How does Magento 2 sku generated automatically?

I want to know how does Magento 2 sku generated automaticlly. I wonder when I type product name while creating new product in admin then its sku is automatically typed in sku field. I researched ...
0
votes
1answer
4k views

Magento2 How to pass argument parameters with multiple class

How to pass argument Parameter configuration inheritance in using theme module inside di.xml here one thing in our theme inside header file inside define code below <?php $objectManager = \...
0
votes
1answer
2k views

Magento 2.3: How do i solve this, Not registered handle, on custom form?

I'm new to Magento, my version is 2.3, i'm getting this error when i open form view: Not registered handle event_form_data_source, i made my custom module Plumtree_Events, here are my files code. /...
0
votes
0answers
50 views

Magento2: setup:di:compile issue

Got the error below when I run the setup:di:compile command [Magento\Framework\Exception\LocalizedException] Source class "\Magento\Framework\EntityManager\OperationInterface" for "Magento\...
1
vote
1answer
374 views

How to create a new price type?

I am now struggling to create a new price type on Magento 2.2.7. Below are what I have tried so far. I have created a module Foo_Bar. And then, first of all, inject the new type into the price pool: ...
0
votes
0answers
51 views

how to use other module data source to new module in magento 2

Hi I want to use the data source of module 1 to module 2 in Magento 2 how I can do this ?? vendor/module2/etc/module.xml <sequence> <module name=vendor_module1/> </sequence> ...
2
votes
1answer
655 views

Magento 2 : di.xml on custom param won't work

I've a class located in \Vendor\Module\Model which is named Test. Here is the constructor of this class : public function __construct(array $map = []) { var_dump($map); die; } I created a di....
1
vote
1answer
54 views

Needed short explanation

I have read many blogs to understand some of the topics in Magento 2 but still not clear about them. They are as follows EAV Dependency Injection Could anyone please explain them shortly? Thanks ...