Magento 2 virtualType

- Magento 2

Magento 2 Development

There is no class Magento\Catalog\Block\Product\Widget\Link in the the catalog_product_link widget declaration, since it is a virtual type. Besides, Magento\Catalog\Block\Product\Widget\Link is an alias to Magento\Catalog\Block\Widget\Link with a custom dependency injection. Please note that an argument entityResource has the Magento\Catalog\Model\ResourceModel\Product type.

As for a normal Magento\Catalog\Block\Widget\Link instance, it has an entityResource argument of the Magento\Catalog\Model\ResourceModel\AbstractResource type.

Hence, with the virtualType declaration we inject the custom entityResource of the Magento\Catalog\Model\ResourceModel\Product type.

Source

 More tips from the CookBook