I have read many docs regarding to proxy classes which is automatically generated by Magento 2 to stop the chain reaction of object instantiation. These docs definition told us that proxy classes should be define via the di.xml and must NOT be specified in the __ constructor method. But when I checked some third party module like Amasty and found that they define the Proxy in __ constructor method.

e.g. path of file: app/code/Amasty/ShopbyBase/Model/Category/Manager.php

in __construct method pass below proxy

\Amasty\ShopbyBase\Model\Category\Manager\Proxy $categoryManager,

and example file is


 \Amasty\ShopbyBase\Model\Source\DisplayMode\Proxy $displayModeSource,

Above examples make me confused because as per definition that proxy classes define only via di.xml.

if anyone have idea about it,please let me know how we should use proxy via xml or via __construct method.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.