Showing results for 
Search instead for 
Did you mean: 

Overriding a Helper

Overriding a Helper

How do you override a helper class? I've overridden a model "Magento\Cms\Model\Page" and all the relevant dependancies to add some additional attributes to pages. All was working just fine until suddenly I refresh the frontend once and get the "There has been an error processing your request". The report shows



Recoverable Error: Argument 3 passed to Magento\Cms\Helper\Page::__construct() must be an instance of Magento\Cms\Model\Page, instance of eworksmedia\PageMenuItems\Model\Page given

I'm not sure what to do to override that file to pass my instance of the Page model to the constructor. I've created the file in eworksmedia\PageMenuItems\Helper\Page.php and even tried adding it to my di.xml:




<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Cms\Model\Page" 
        type="eworksmedia\PageMenuItems\Model\Page" />
    <preference for="Magento\Cms\Helper\Page" 
        type="eworksmedia\PageMenuItems\Helper\Page" />

But it's not working. The weird thing is it was working just fine for a good 4 hours then suddenly decided to not work after not touching anything. Any help is greatly appreciated