Skip to content

Commit c3f9f3d

Browse files
committed
MC-35573: Share Wish List | Getting error while user wants to add shared items in cart
1 parent 25772e6 commit c3f9f3d

File tree

1 file changed

+8
-4
lines changed
  • app/code/Magento/Wishlist/Controller/Shared

1 file changed

+8
-4
lines changed

app/code/Magento/Wishlist/Controller/Shared/Cart.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Wishlist\Controller\Shared;
79

810
use Magento\Catalog\Model\Product\Exception as ProductException;
911
use Magento\Checkout\Helper\Cart as CartHelper;
1012
use Magento\Checkout\Model\Cart as CustomerCart;
13+
use Magento\Framework\App\Action\Action;
1114
use Magento\Framework\App\Action\Context as ActionContext;
12-
use Magento\Framework\App\Action\HttpGetActionInterface;
15+
use Magento\Framework\App\Action\HttpPostActionInterface;
16+
use Magento\Framework\Controller\Result\Redirect;
1317
use Magento\Framework\Controller\ResultFactory;
1418
use Magento\Framework\Escaper;
1519
use Magento\Framework\Exception\LocalizedException;
@@ -23,7 +27,7 @@
2327
*
2428
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2529
*/
26-
class Cart extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface
30+
class Cart extends Action implements HttpPostActionInterface
2731
{
2832
/**
2933
* @var CustomerCart
@@ -80,7 +84,7 @@ public function __construct(
8084
* If Product has required options - redirect
8185
* to product view page with message about needed defined required options
8286
*
83-
* @return \Magento\Framework\Controller\Result\Redirect
87+
* @return Redirect
8488
*/
8589
public function execute()
8690
{
@@ -120,7 +124,7 @@ public function execute()
120124
} catch (\Exception $e) {
121125
$this->messageManager->addExceptionMessage($e, __('We can\'t add the item to the cart right now.'));
122126
}
123-
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
127+
/** @var Redirect $resultRedirect */
124128
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
125129
$resultRedirect->setUrl($redirectUrl);
126130
return $resultRedirect;

0 commit comments

Comments
 (0)