Skip to main content
1 of 2
ali gh
  • 731
  • 2
  • 7
  • 22

How to override core helper in magento 2?

I writed a preference for class Magento\Catalog\Helper\Image but i got this error:

Recoverable Error: Argument 4 passed to Magento\Checkout\Block\Cart\Sidebar\Interceptor::__construct() must be an Instance of Magento\Catalog\Helper\Image, instance of RMI\ImageCDN\Helper\Image given, called in C:\xampp\htdocs\magento\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php on line 107 and defined in C:\xampp\htdocs\magento\var\generation\Magento\Checkout\Block\Cart\Sidebar\Interceptor.php on line 11

If preference is not a good way to override a helper in core , what is the solution?

ali gh
  • 731
  • 2
  • 7
  • 22