Magento2: How to redirect user from cart page to any other page?
-
14-04-2021 - |
Question
I have a magento site in ver 2.3.5-p1
I want to redirect /checkout/cart/
this page to homepage, because my site is Quote only store and so no need of normal cart page. For that I have created a module to override Magento\Checkout\Controller\Cart\Index
this controller. Then added following code in my new controller:
namespace MyCompany\RedirectShoppingCart\Controller\Cart;
class Index extends \Magento\Checkout\Controller\Cart\Index
{
/**
* Shopping cart display action
*
* @return \Magento\Framework\View\Result\Page
*/
public function execute()
{
return $this->_response->setRedirect('/quotation/quote/', 301);
}
}
But this is giving following error:
Fatal error: Uncaught TypeError: Argument 2 passed to Amazon\Login\Plugin\CartController::afterExecute() must implement interface Magento\Framework\Controller\ResultInterface,
instance of Magento\Framework\App\Response\Http\Interceptor given, called in /var/www/html/vendor/magento/framework/Interception/Interceptor.php on line 146 and defined in /var/www/html/vendor/amzn/login-with-amazon-module/Plugin/CartController.php:44
Please help!
Solution
because my site is Quote only store and so no need of normal cart page.
Based on your statement above - I'm assuming that you DONT need/leverage the Amazon modules that ship OOTB with Magento 2.3.5.
If that is a valid assessment, your simplest option would be to disable the following Amazon modules:
Amazon_Login
Amazon_Core
Amazon_Payment
And this can be achieved - via the CLI - using the following commands:
bin/magento module:disable Amazon_Login
bin/magento module:disable Amazon_Core
bin/magento module:disable Amazon_Payment
Good Luck!
Cheers,
Sharath
OTHER TIPS
You can disable this plugin. File di.xml
<type name="Magento\Checkout\Controller\Cart\Index">
<plugin name="amazon_login_cart_controller" disabled="true" />
</type>