Skip to main content

Questions tagged [virtualtype]

Virtual types are used in the Dependency Injection container of Magento 2

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

How to override Mass action in magento 2?

How to override Mass action in Magento module. I want to override below files. Vendorname\ModuleName\Ui\Component\MassAction\Status to my custom module.
Paren Sutreja's user avatar
1 vote
1 answer
420 views

How argument and item node work in di.xml in Magento 2?

I just wanted to know in deeply how argument, type , virtual type and item work in di.xml
Mark's user avatar
  • 63
3 votes
0 answers
146 views

Magento 2 Console command by using virtualTypes

I tried this solution but the arguments are empty when I debug the command class. It should be possible to create command classes by using a virtualType, no? The constructor arguments are empty in ...
den3988's user avatar
  • 31
0 votes
2 answers
41 views

How to remove extra dash from virtual category page meta title

I have a few virtual categories set up in my top menu. When I go to a specific brand the meta title on my browsers tab shows a dash character "-" before the Brand Name. Looking for a ...
Infinri's user avatar
  • 121
0 votes
1 answer
880 views

Virtual Type in Magento 2

I am trying to understand the virtual type with the help of existing blog and video tutorial. It's too hard to understand the concept and it's too confused Here I'want some good understandable example ...
senthil's user avatar
  • 1,729
2 votes
1 answer
501 views

Plugin class doesn't exist for plugins of type virutal

I have a base plugin which accepts blockName(String) as a parameter. Based on that value I have created three virtual type plugins and used them. Below are the codes. di.xml <virtualType name=&...
Mathanagopal S's user avatar
0 votes
1 answer
301 views

how to disable di.xml virtual types from vendor in custom module

I am currently experiencing an issue where a vendor module is using MSI, however we needed to disable it via composer completly ( magento 2.3.4 ) The vendor module in question is the amasty layered ...
Rotariu Dan Andrei's user avatar
0 votes
1 answer
213 views

Error with virtualType collection construct

I am upgrading from Magento 2.2.4 to 2.3.5. I have this collection using virtualTyp made by someone else. I don't understand what's going on. Anyone can help ? THanks !! <virtualType name="...
Gustavo Ulyssea's user avatar
0 votes
1 answer
1k 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 ...
CvRChameleon's user avatar
1 vote
1 answer
464 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\...
frezq's user avatar
  • 155
3 votes
1 answer
3k views

How to Create a Sliding Modal Popup on Custom Button in Magento2 admin

How can we create a modal popup on a custom button like it does when we click on the "Add Attribute" button when editing the product in the backend. I want to create a similar feature on a custom ...
hardik malkani's user avatar
1 vote
1 answer
2k 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:...
Amit Singh's user avatar
  • 1,775
0 votes
2 answers
1k views

Magento 2 Virtual Type real time usage example

I am working in Magento2, in that, I hear about some new concept virtual type, so I like to use the virtual type in my development(if it's needed). But I have gone through so many blogs to understand,...
senthil's user avatar
  • 1,729
0 votes
1 answer
758 views

Magento 2: Ui Component - Magento\Customer\Model\Session can't return current customer

I've got an issue using ui component on front in a large module. The model I'm using for my grid is used at several other points. But I discovered my configuration in di.xml is doing some strange ...
Mric's user avatar
  • 61
1 vote
1 answer
719 views

Injecting additional dependencies into a class - Magento 2.3

I am trying to inject additional dependencies into a class. The class in question is: \Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo The construct of this class looks like: public ...
Goose84's user avatar
  • 2,631
2 votes
1 answer
514 views

can virtual types be used as cronjob instances

I tried to use a virtual type in cronjob as instance but without any success. When I use a real class it works as expected. Is there any hint to get virtual types working in cronjobs? crontab.xml: &...
Enrico Thies's user avatar
2 votes
0 answers
111 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> ...
Pasha's user avatar
  • 65
1 vote
1 answer
2k views

Injecting object through virtual type not working

I am using this config in di.xml <virtualType name="ourFirstVirtualType" type="Test\Testmod\Model\Newmodelclass"> <arguments> <argument name="test_object" xsi:type=...
HungryDB's user avatar
  • 906
7 votes
1 answer
842 views

Can Virtual Types be used as controllers?

This is more of a curiosity than a "need". I have a few controller actions that do exactly the same thing, just some parameters differ. I'm trying to reduce the amount of code I write and have one ...
Marius's user avatar
  • 198k
2 votes
1 answer
1k views

Const argument in virtual type breaks magento2 [closed]

So, I'm using the code from here sample-payment and I have in di.xml the following code: <!-- Payment Method Facade configuration --> <virtualType name="SamplePaymentGatewayFacade" type="...
Edwin's user avatar
  • 151
4 votes
1 answer
1k views

How to set ifconfig for di.xml magento 2

I want set ifconfig configuration for below code: First code in di.xml <virtualType name="searchFilterList" type="Magento\Catalog\Model\Layer\FilterList"> <arguments> <...
Kartik Asodariya's user avatar
7 votes
2 answers
2k views

Magento 2. Injecting a virtual type results in array instead of object

I'm having some trouble with virtual types. I've done some research and this is what I have. 0: A class which takes a string argument 1: A virtual type based on above class with a constant value for ...
vitoriodachef's user avatar
0 votes
2 answers
1k views

Magento2 unable to create|use a virtual type

I'm trying to make use of a virtual type. I'm following the docs on this and everything should be pretty straight forward yet I'm kinda stuck. This is what I have. The class. namespace Company\...
vitoriodachef's user avatar
4 votes
2 answers
2k views

Can a virtual type be used as a dependency for a class?

I'm trying to do something new with virtual types. I understand that you can create these in your di.xml and use them as arguments for other types in di.xml. But can I also declare a virtual type and ...
Giel Berkers's user avatar
  • 12.3k
2 votes
1 answer
1k views

How to extends virtual type from di.xml

Is it possible to extends virtual type class declared in di.xml ? If yes how ?
bakalov's user avatar
  • 131
4 votes
2 answers
1k views

Magento 2 not respecting preference?

I'm trying to make a preference to override the PayPal Module's ResponseValidator class, so that i can save the validation errors for easier debugging on our end if a customer's checkout fails. The ...
Zachary Craig's user avatar
0 votes
1 answer
915 views

VirtualType not created / class not found (after cache clear)

Virtual Type XML Declaration: <virtualType name="SliderSlideImageUploader" type="Magento\Catalog\Model\ImageUploader"> <arguments> <argument name="baseTmpPath" xsi:type="...
LM_Fielding's user avatar
  • 1,543
0 votes
0 answers
302 views

Assign template of block via virtualType in Magento 2?

It's possible to assign template of the block via virtualType? app/code/Vendor/Module/etc/frontend/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
Khoa TruongDinh's user avatar
6 votes
0 answers
1k views

How to override class Virtual Type class

I saw this, but it don't work for me. How to override Virtual Type class in Magento 2 <virtualType name="categoryFilterList" type="Magento\Catalog\Model\Layer\FilterList"> <arguments>...
zhartaunik's user avatar
  • 3,846
1 vote
1 answer
545 views

Receiving object specific class which was injected in constructor by three-part extension

For example, anybody can modify this virtual type magento/module-catalog/etc/di.xml: <virtualType name="Magento\Catalog\Model\Layer\Search\Context" type="Magento\Catalog\Model\Layer\Context">...
sergei.sss's user avatar
  • 1,179
5 votes
1 answer
1k views

Change <item> node class via di.xml

If I have something like this: <type name="Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Composite"> <arguments> <argument name="modifiers" xsi:type="array">...
Bartosz Kubicki's user avatar
2 votes
1 answer
4k views

Magento2 - VirtualType argument replacement

I'm trying to remove the category filter in category view. But apart from that, my question is more about Magento 2 itself. in di.xml of Magento_CatalogSearch , you just have to comment the "category"...
Pol Ravalitera's user avatar
0 votes
1 answer
293 views

Can virtual types be used as source models for EAV attributes?

I'm creating my own EAV entity and one of the attributes of my entity has the type select so it requires a source model. But I don't want to create my own class just for this attribute since I already ...
Marius's user avatar
  • 198k
10 votes
2 answers
4k views

Magento 2: virtual types plugins

I'm confused by Magento 2 documentation regarding plugins: It is first said that: Plugins cannot be used with virtual types But then it is said that: You can specify a class, interface, or ...
Raphael at Digital Pianism's user avatar
3 votes
1 answer
7k views

How to Override or Extend protected or parent function in Magento 2 using Plugin

I need to override protected function or parent function ex Magento\Checkout\Controller\Cart\Add is extended from Magento\Checkout\Controller\Cart and getBackUrl() is a Magento\Checkout\Controller\...
Pradeep Kumar's user avatar
11 votes
2 answers
1k views

Magento 2: Virtual Type Naming Convention

Date: June 1, 2015 (given the changing nature of Magento 2) In Magento 2, you can configure a "virtual type" in a module's di.xml configuration file. These virtual types allow you to change the ...
Alana Storm's user avatar
  • 44.4k
60 votes
3 answers
30k views

What is the difference between type and virtualType

In the di.xml that comes with Magento2 there is a node type and a node virtualType. My questions is what is this virtualType and in what case should it be used instead of type? In some places it ...
David Manners's user avatar