Magento 2 How to Override Core Block, Model and controller
Magento 2 How to Override Core Block, Model and controller
Create di.xml file at app/code/{Vendor}/{Module}/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="Magento\Catalog\Controller\Product\View" type="{Vendor}\{Module}\Controller\Catalog\Product\View" /></config>
Create File View.php at app/code/{Vendor}/{Module}/Controller/Catalog/Product/
<?php
namespace Vendor\Module\Controller\Catalog\Product;
class View extends \Magento\Catalog\Controller\Product\View
{
public function execute(){
echo 'Hello Called from Overriden File '.__DIR_;exit;
}
}
If like efforts, Please share, comment and subscribe for future posts and inspire more.
Comments
Post a Comment