need to override Admin sales/order/index controller, but still getting 404. Below the Steps I take to override -
Created My Custom Module
app/code/A2bizz/Order/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'A2bizz_Order', __DIR__ );
app/code/A2bizz/Order/etc/module.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="A2bizz_Order" setup_version="2.0.0" schema_version="2.0.0"> <sequence> <module name="Magento_Sales"/> <module name="Magento_Rule"/> <module name="Magento_Catalog"/> <module name="Magento_Customer"/> <module name="Magento_Payment"/> <module name="Magento_SalesSequence"/> </sequence> </module> </config>
app/code/A2bizz/Order/Controller/Adminhtml/Order/Index.php
<?php namespace A2bizz\Order\Controller\Adminhtml\Order; class Index extends \Magento\Sales\Controller\Adminhtml\Order\Index { public function execute() { $this->messageManager->addSuccess('Message from new admin controller.'); // Do your stuff here return parent::execute(); } }
app/code/A2bizz/Order/etc/adminhtml/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="Magento\Sales\Controller\Adminhtml\Order\Index" type="A2bizz\Order\Controller\Adminhtml\Order\Index" /> </config>
if anyone can help me on what I am doing wrong. Thanks
Hello,
Make sure di compilation not done.
try to remove generated/code and generated/metdata and cache flush and try it.