Skip to content

Commit 6cf13db

Browse files
author
Patrick McLain
committed
Allow wishlist share when all items are out of stock
Clicking `Share` on the wishlist view page updates and saves the wishlist before redirecting to the share page. The redirection to the share page only happens when the post body includes wishlist descriptions. Because qty and comment are disabled for out of stock wishlist items these properties are not sent with the post resulting in the share redirect being unreachable when all items are out of stock. This commit updates the controller flow separating the logic conditions for saving and sharing. This allows sharing wishlist where all items are out of stock.
1 parent 6159dc8 commit 6cf13db

File tree

1 file changed

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

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ public function execute()
7070
}
7171

7272
$post = $this->getRequest()->getPostValue();
73-
if ($post && isset($post['description']) && is_array($post['description'])) {
73+
$resultRedirect->setPath('*', ['wishlist_id' => $wishlist->getId()]);
74+
if (!$post) {
75+
return $resultRedirect;
76+
}
77+
78+
if (isset($post['description']) && is_array($post['description'])) {
7479
$updatedItems = 0;
7580

7681
foreach ($post['description'] as $itemId => $description) {
@@ -136,13 +141,12 @@ public function execute()
136141
$this->messageManager->addErrorMessage(__('Can\'t update wish list'));
137142
}
138143
}
144+
}
139145

140-
if (isset($post['save_and_share'])) {
141-
$resultRedirect->setPath('*/*/share', ['wishlist_id' => $wishlist->getId()]);
142-
return $resultRedirect;
143-
}
146+
if (isset($post['save_and_share'])) {
147+
$resultRedirect->setPath('*/*/share', ['wishlist_id' => $wishlist->getId()]);
144148
}
145-
$resultRedirect->setPath('*', ['wishlist_id' => $wishlist->getId()]);
149+
146150
return $resultRedirect;
147151
}
148152
}

0 commit comments

Comments
 (0)