Skip to content

Commit 8a9f574

Browse files
committed
AC-10922: Add product to wishlist issue with logged out user
1 parent 4ff8b0f commit 8a9f574

File tree

1 file changed

+6
-3
lines changed
  • app/code/Magento/Wishlist/Controller/Index

1 file changed

+6
-3
lines changed

app/code/Magento/Wishlist/Controller/Index/Add.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Action\HttpPostActionInterface;
1313
use Magento\Framework\Controller\Result\Redirect;
1414
use Magento\Framework\Data\Form\FormKey\Validator;
15+
use Magento\Framework\DataObject;
1516
use Magento\Framework\Exception\LocalizedException;
1617
use Magento\Framework\Exception\NotFoundException;
1718
use Magento\Framework\Exception\NoSuchEntityException;
@@ -101,7 +102,9 @@ public function execute()
101102
/** @var Redirect $resultRedirect */
102103
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
103104
$session = $this->_customerSession;
104-
$requestParams = $this->getRequest()->getParams();
105+
$data = empty($session->getBeforeWishlistUrl())
106+
? $this->getRequest()->getParams()
107+
: $session->getBeforeRequestParams();
105108
if (!$this->formKeyValidator->validate($this->getRequest())) {
106109
return $resultRedirect->setPath('*/');
107110
}
@@ -111,7 +114,7 @@ public function execute()
111114
throw new NotFoundException(__('Page not found.'));
112115
}
113116

114-
$productId = isset($requestParams['product']) ? (int)$requestParams['product'] : null;
117+
$productId = isset($data['product']) ? (int)$data['product'] : null;
115118
if (!$productId) {
116119
$resultRedirect->setPath('*/');
117120
return $resultRedirect;
@@ -130,7 +133,7 @@ public function execute()
130133
}
131134

132135
try {
133-
$buyRequest = new \Magento\Framework\DataObject($requestParams);
136+
$buyRequest = new DataObject($data);
134137

135138
$result = $wishlist->addNewItem($product, $buyRequest, true);
136139
if (is_string($result)) {

0 commit comments

Comments
 (0)