15 use Psr\Log\LoggerInterface as Logger;
115 $isOwner =
$wishlist->isOwner($this->customerSession->getCustomerId());
127 $disableAddToCart =
$item->getProduct()->getDisableAddToCart();
131 if (isset($qtys[
$item->getId()])) {
132 $qty = $this->quantityProcessor->process($qtys[
$item->getId()]);
137 $item->getProduct()->setDisableAddToCart($disableAddToCart);
140 $addedProducts[] =
$item->getProduct();
142 }
catch (LocalizedException $e) {
143 if ($e instanceof ProductException) {
144 $notSalable[] =
$item;
146 $messages[] =
__(
'%1 for "%2".', trim($e->getMessage(),
'.'),
$item->getProduct()->getName());
153 }
catch (\Exception $e) {
154 $this->logger->critical($e);
155 $messages[] =
__(
'We can\'t add this item to your shopping cart right now.');
160 $indexUrl = $this->helper->getListUrl(
$wishlist->getId());
162 $indexUrl = $this->urlBuilder->getUrl(
'wishlist/shared', [
'code' =>
$wishlist->getSharingCode()]);
164 if ($this->cartHelper->getShouldRedirectToCart()) {
165 $redirectUrl = $this->cartHelper->getCartUrl();
166 }
elseif ($this->redirector->getRefererUrl()) {
167 $redirectUrl = $this->redirector->getRefererUrl();
169 $redirectUrl = $indexUrl;
174 foreach ($notSalable as
$item) {
178 'We couldn\'t add the following product(s) to the shopping cart: %1.',
185 $this->messageManager->addError(
$message);
187 $redirectUrl = $indexUrl;
190 if ($addedProducts) {
194 }
catch (\Exception $e) {
195 $this->messageManager->addError(
__(
'We can\'t update the Wish List right now.'));
196 $redirectUrl = $indexUrl;
200 foreach ($addedProducts as
$product) {
205 $this->messageManager->addSuccess(
206 __(
'%1 product(s) have been added to shopping cart: %2.', count($addedProducts), join(
', ',
$products))
210 $cart->save()->getQuote()->collectTotals();
212 $this->helper->calculate();
elseif(isset( $params[ 'redirect_parent']))
__construct(Session $customerSession, LocaleQuantityProcessor $quantityProcessor, Cart $cart, Logger $logger, WishlistHelper $helper, CartHelper $cartHelper, UrlInterface $urlBuilder, MessageManager $messageManager, RedirectInterface $redirector)