Questions tagged [di]

Denotes questions related to Dependency Injection in Magento 2.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 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
31 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
20 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&...
0
votes
0answers
5 views

How to set use address attributes

I have attributes wich display in customer_form_address_user_attributes BLOCK. How i can pass or change attributes. Maybe some xml or di?
1
vote
3answers
107 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
20 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
46 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
0answers
16 views

Magento2 : Join Another Table in Existing Collection

Lets say, Third party collection class is as below: namespace Vendor\ShipRule\Model\ResourceModel\Rule; class Collection extends Magento\Framework\Model\ResourceModel\Db\Collection\...
0
votes
0answers
15 views

Overwrite EmailNotification from Module Customer

Can anyone let me know how can I Over write EmailNotification File in our custom module. I tried this way by modifying methods of private function sendEmailTemplate( $customer, $...
0
votes
2answers
65 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
40 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://...
0
votes
1answer
29 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\...
0
votes
0answers
22 views

Mangeto2: instantiate Helper if exists

I am developing a module and I need to instantiate a helper of another module only if this module exists (is installed). use \Magento\CatalogSearch\Helper\Data as CatalogSearch; use \Magento\...
1
vote
1answer
203 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
114 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
45 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
230 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:...
6
votes
0answers
177 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
81 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
35 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/...
16
votes
5answers
4k 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
73 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
36 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
377 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
106 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
51 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
216 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
2k 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
1k 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
47 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
103 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
27 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
146 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
50 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 ...
1
vote
1answer
22 views

Are there any restrictions on classes you can override with preference in di.xml

When overriding a class with a custom one using the di.xml, are there any restrictions on what class you can override? I have tried overriding a class of a third party module, but it does not appear ...
2
votes
1answer
167 views

Preference class doesn't work

I'm trying to replace a class method "wrapResult" from: \Magento\Catalog\Pricing\Render\FinalPriceBox Never enter into this method. Try to stop the execution with die () or with xdebug, enter ...
0
votes
0answers
109 views

Error Class not found before deleting generated folder

I have created a preference to override a class but constantly getting error "Class not found" before deleting "generated" folder content: Error: Fatal error: Uncaught Error: Class 'Vendor\Module\...
1
vote
1answer
1k views

setup:di:compile VS rm -f var/generation

When we work in di.xml file for extend the functionality then we need to php bin/magento setup:di:compile setup:di:compile take 30 to 40 second or long in window. if we remove the generation folder/...
0
votes
2answers
27 views

Magento 2 describe attrubute property used in Plugin method

I am trying to create a simple module and I can't find the propose of the attribute name and type inside the tag type and plugin in di.xml. can anyone describe attribute name used in plugin? <?...
1
vote
0answers
69 views

Magento 2 getting interface implementation from admin config

I have an interface which gives me the country in which the customer is located. interface CustomerLocatorInterface { public function getLocalCountryCode(); } And I have two possible ...
1
vote
1answer
1k views

What is the Use of Type and Virtual Types(di.xml) in Magento2?

I want to know clear about Type and Virtual Types in di.xml with examples. When we can use it. Please share simple example to understand concept. Note please go through the practical examples.
0
votes
1answer
37 views

Best practice to extend an object

What's the best practice and recommended way to extend an object like \Magento\Store\Model\Store with a new object property. I want to do something like this: $storeManager; //StoreManagerInterface ...
1
vote
3answers
484 views

Confused about using proxies

I kind of understand how the logic and the benefit of proxies in Magento 2 di. But can anybody tell me, how to use it?! Alan Storm use the generated proxy class, for example, I would call \Magento\...
10
votes
1answer
586 views

The purpose of the http verbs interfaces

In Magento 2.3 there are some interfaces for all the http verbs Magento\Framework\App\Action\HttpPostActionInterface Magento\Framework\App\Action\HttpGetActionInterface, ... All of them are empty ...
0
votes
1answer
2k views

Magento 2 Overwrites Topmenu.php In Module But Menu Nav Disappears

My di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <...
8
votes
3answers
534 views

What is the use of “mapping” node in di.xml in Magento 2?

I am using Magento 2.2.5 have a look on file vendor\magento\module-sales\etc\di.xml <type name="Magento\Payment\Model\Checks\SpecificationFactory"> <arguments> <...
1
vote
1answer
703 views

How can i filter in sales order grid magento 2?

While i am using same code for filter it's working but i have break other grid like customer,invoice,cms page and get error "Not registered handle cms_page_listing_data_source" While i have moved di....
2
votes
0answers
90 views

Exception after bin/magento setup:di:compile and adding virtualType

I was adding this: <virtualType name="Test\Faq\Model\ResourceModel\VisitStat\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult"> <arguments> ...