I want to override cartcontroller(checkout/controller/cart.php) by my module controller. Can anyone help me please? Any help will be appreciated.
I just tried, But it is not working. My files are,
\code \StwBuyXGetY \BuyXGetY \etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Controller\Cart"
type="StwBuyXGetY\BuyXGetY\Controller\Checkout\Cart" />
</config>
\code \StwBuyXGetY \BuyXGetY \Controller\Checkout\Cart.php
<?php
namespace StwBuyXGetY\BuyXGetY\Controller\Checkout;
class Cart extends \Magento\Checkout\Controller\Cart
{
public function execute(){
echo 'Hello World'; exit;}
}
Please help. (Note:- I just put the dummy content in cart.php, this is not the actual function.)