Hi so i wrote this code to override a method in the woom cmstree module. But it seems like, something is wrong and i have used an entire day to figure it out, without any success.
My Vendor/MyModule/Block/Widget/Children.php
<?php
namespace Vendor\MyModule\Block\Widget;
class Children extends \Woom\CmsTree\Block\Widget\Children
{
protected $belongsToMenu = "";
public function prepareLinks($treeChildren, $first = false)
{
$html = '';
some random code
return $html;
}
}
My etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Woom\CmsTree\Block\Widget\Children" type="Vendor\MyModule\Block\Widget\Children" />
</config>
So this is how i did it. And i of course got the registration file and module.xml
But when i go to the page where this widget is used i get this error
[2021-03-04 20:56:22] main.CRITICAL: Error: Class 'Vendor\Mymodule\Block\Widget\Children' not found in /home/sonose2/public_html/generated/code/Vendor/Mymodule/Block/Widget/Children/Interceptor.php:7
I have been look at some examples but the are exact as mine and i have been trying alot of other stuff and now i ran out of ideas what to do.
registration.php
andetc/module.xml
files and make sure that you useMyModule
instead ofMymodule
(either way is OK, but it's really important it's the same everywhere throughout the module). Also, if your preference doesn't want to work, try moving the preference frometc/di.xml
toetc/frontend/di.xml
– Zankar Mar 5 at 6:45