Skip to content

Commit 9200059

Browse files
committed
ACP2E-341::Product is not getting added in wishlist from product list page and product view page when customer confirms account from confirmation email - Utilized URL Helper to prepare Backurl
1 parent 1afe1ea commit 9200059

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

app/code/Magento/Wishlist/Plugin/SaveWishlistDataAndAddReferenceKeyToBackUrl.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Customer\Model\Session as CustomerSession;
1515
use Magento\Customer\Model\EmailNotificationInterface;
1616
use Magento\Framework\UrlInterface;
17+
use Magento\Framework\Url\Helper\Data as UrlHelper;
1718

1819
/**
1920
* Cache wishlist data & Modify back Url
@@ -37,19 +38,27 @@ class SaveWishlistDataAndAddReferenceKeyToBackUrl
3738
*/
3839
private $urlBuilder;
3940

41+
/**
42+
* @var UrlHelper
43+
*/
44+
private $urlHelper;
45+
4046
/**
4147
* @param DataSerializer $dataSerializer
4248
* @param CustomerSession $customerSession
4349
* @param UrlInterface $urlBuilder
50+
* @param UrlHelper $urlHelper
4451
*/
4552
public function __construct(
4653
DataSerializer $dataSerializer,
4754
CustomerSession $customerSession,
48-
UrlInterface $urlBuilder
55+
UrlInterface $urlBuilder,
56+
UrlHelper $urlHelper
4957
) {
5058
$this->dataSerializer = $dataSerializer;
5159
$this->customerSession = $customerSession;
5260
$this->urlBuilder = $urlBuilder;
61+
$this->urlHelper = $urlHelper;
5362
}
5463

5564
/**
@@ -77,14 +86,7 @@ public function beforeNewAccount(
7786
&& ($backUrl !== null && strpos($backUrl, 'wishlist/index/add') !== false)
7887
) {
7988
$token = $this->dataSerializer->serialize($this->customerSession->getBeforeWishlistRequest());
80-
$query = [];
81-
if (strpos($backUrl, '?') !== false) {
82-
$queryString = explode('?', $backUrl);
83-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
84-
parse_str($queryString[1], $query);
85-
}
86-
$query['token'] = $token;
87-
$backUrl = $this->urlBuilder->getUrl('wishlist/index/add', ['_query' => $query]);
89+
$backUrl = $this->urlHelper->addRequestParam($backUrl, ['token' => $token]);
8890
}
8991

9092
return [$customer, $type, $backUrl, $storeId, $sendemailStoreId];

0 commit comments

Comments
 (0)