September 2018
Beginner to intermediate
218 pages
4h 27m
English
Virtual types are a very neat feature of Magento that allow us to change the arguments of a specific injectable dependency and thus change the behavior of a particular class type.
The <MAGENTO_DIR>/module-checkout/etc/di.xml file provides a simple example of virtualType and its usage:
<virtualType name="Magento\Checkout\Model\Session\Storage" type="Magento\Framework\Session\Storage"> <arguments> <argument name="namespace" xsi:type="string">checkout</argument> </arguments></virtualType><type name="Magento\Checkout\Model\Session"> <arguments> <argument name="storage" xsi:type="object">Magento\Checkout\Model\Session\Storage</argument> </arguments></type>
The virtualType here (virtually) extends Magento\Framework\Session\Storage ...
Read now
Unlock full access