Questions tagged [di]

Denotes questions related to Dependency Injection in Magento 2.

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

How can I get the admin edit user url key for a specific user if I have the user_id and account info, what are the classes/methods for di?

Example: http://localhost/admin/admin/user/edit/user_id/5/key/db1082c352e51cfb817ce0335dd060cf6e953568daf2da25cca24eadb04dc884/ I want to return '...
user avatar
0 votes
1 answer
37 views

Inject dependency based on php version

I use soap to do some calls to a remote server, php has changed method signature for __doRequest between php 7.4 & 8.x, is there any di.xml tag that can conditionally change the loaded class based ...
user avatar
0 votes
1 answer
57 views

Override Abstract class in Magento 2 not working

I'm using magento v2.4.3, i tried to override \Magento\Customer\Model\Address\AbstractAddress like this: app/code/Vendor/Module/etc/module.xml <?xml version="1.0" ?> <config xmlns:...
user avatar
  • 68
0 votes
2 answers
61 views

Magento 2 - How to disable a plugin

Problem: I am using the extension Fooman_PdfCustomiser. I need to disable the plugin named fooman_pdfcustomiser_paymentinfoblock. vendor/fooman/pdfcustomiser-implementation-m2/src/etc/di.xml: <...
user avatar
  • 2,403
0 votes
2 answers
33 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="...
user avatar
0 votes
1 answer
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\...
user avatar
0 votes
1 answer
521 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 ...
user avatar
  • 71
0 votes
2 answers
102 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 ...
user avatar
  • 2,403
0 votes
2 answers
50 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/...
user avatar
0 votes
0 answers
120 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\...
user avatar
0 votes
1 answer
31 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/...
user avatar
  • 1
0 votes
0 answers
101 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\...
user avatar
  • 1
0 votes
1 answer
323 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\...
user avatar
0 votes
2 answers
232 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 ...
user avatar
  • 2,403
0 votes
1 answer
86 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: /...
user avatar
  • 383
0 votes
1 answer
108 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"?&...
user avatar
  • 2,403
1 vote
2 answers
547 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/...
user avatar
0 votes
1 answer
83 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\...
user avatar
0 votes
1 answer
84 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, ...
user avatar
  • 21
0 votes
2 answers
266 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\...
user avatar
  • 13
0 votes
1 answer
171 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....
user avatar
  • 359
0 votes
1 answer
894 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 ...
user avatar
  • 33
0 votes
1 answer
922 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\...
user avatar
  • 1,203
0 votes
1 answer
812 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&...
user avatar
  • 526
1 vote
3 answers
630 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-...
user avatar
1 vote
1 answer
346 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"...
user avatar
1 vote
0 answers
25 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 ...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 760
0 votes
1 answer
589 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 ...
user avatar
0 votes
2 answers
242 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 /...
user avatar
  • 384
0 votes
2 answers
162 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://...
user avatar
1 vote
1 answer
219 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\...
user avatar
  • 155
1 vote
1 answer
1k 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. ...
user avatar
  • 3,572
2 votes
1 answer
674 views

Magento 2 Override public static method of framework 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 ...
user avatar
0 votes
0 answers
88 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....
user avatar
  • 1,047
1 vote
1 answer
934 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:...
user avatar
  • 1,645
10 votes
1 answer
778 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\...
user avatar
  • 75.7k
0 votes
1 answer
144 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 ...
user avatar
  • 1,187
1 vote
1 answer
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/...
user avatar
18 votes
6 answers
7k 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\...
user avatar
1 vote
0 answers
134 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 ...
user avatar
  • 13
2 votes
0 answers
82 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?
user avatar
1 vote
1 answer
882 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 ...
user avatar
0 votes
3 answers
148 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
user avatar
  • 61
1 vote
1 answer
58 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:...
user avatar
  • 195k
0 votes
1 answer
551 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 ...
user avatar
0 votes
1 answer
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 = \...
user avatar
  • 1,597
0 votes
1 answer
3k 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. /...
user avatar
0 votes
0 answers
51 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\...
user avatar
  • 1,127
1 vote
1 answer
493 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: ...
user avatar
  • 579