Exemple #1
0
 /**
  * Add all items from wishlist to shopping cart
  *
  * @return void
  */
 public function execute()
 {
     $wishlist = $this->wishlistProvider->getWishlist();
     if (!$wishlist) {
         $this->_forward('noroute');
         return;
     }
     $redirectUrl = $this->itemCarrier->moveAllToCart($wishlist, $this->getRequest()->getParam('qty'));
     $this->getResponse()->setRedirect($redirectUrl);
 }
 public function testExecuteWithWishlist()
 {
     $wishlist = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock();
     $this->wishlistProvider->expects($this->once())->method('getWishlist')->willReturn($wishlist);
     $this->request->expects($this->once())->method('getParam')->with('qty')->will($this->returnValue(2));
     $this->itemCarrier->expects($this->once())->method('moveAllToCart')->with($wishlist, 2)->will($this->returnValue('http://redirect-url.com'));
     $this->response->expects($this->once())->method('setRedirect')->will($this->returnValue('http://redirect-url.com'));
     $controller = $this->getController();
     $controller->execute();
 }
Exemple #3
0
 /**
  * Shared wishlist view page
  *
  * @return void
  */
 public function execute()
 {
     $wishlist = $this->wishlistProvider->getWishlist();
     $customerId = $this->customerSession->getCustomerId();
     if ($wishlist && $wishlist->getCustomerId() && $wishlist->getCustomerId() == $customerId) {
         $this->getResponse()->setRedirect($this->_objectManager->get('Magento\\Wishlist\\Helper\\Data')->getListUrl($wishlist->getId()));
         return;
     }
     $this->registry->register('shared_wishlist', $wishlist);
     $this->_view->loadLayout();
     $this->_view->getLayout()->initMessages();
     $this->_view->renderLayout();
 }
Exemple #4
0
 /**
  * Add all items from wishlist to shopping cart
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $wishlist = $this->wishlistProvider->getWishlist();
     if (!$wishlist) {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
         $resultForward->forward('noroute');
         return $resultForward;
     }
     $redirectUrl = $this->itemCarrier->moveAllToCart($wishlist, $this->getRequest()->getParam('qty'));
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     $resultRedirect->setUrl($redirectUrl);
     return $resultRedirect;
 }
 /**
  * Shared wishlist view page
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $wishlist = $this->wishlistProvider->getWishlist();
     $customerId = $this->customerSession->getCustomerId();
     if ($wishlist && $wishlist->getCustomerId() && $wishlist->getCustomerId() == $customerId) {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
         $resultRedirect->setUrl($this->_objectManager->get('Magento\\Wishlist\\Helper\\Data')->getListUrl($wishlist->getId()));
         return $resultRedirect;
     }
     $this->registry->register('shared_wishlist', $wishlist);
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
     return $resultPage;
 }
Exemple #6
0
    public function testExecuteWithNoWishlist()
    {
        $this->wishlistProviderMock->expects($this->once())
            ->method('getWishlist')
            ->willReturn(false);
        $this->resultForwardMock->expects($this->once())
            ->method('forward')
            ->with('noroute')
            ->willReturnSelf();

        $this->assertSame($this->resultForwardMock, $this->allcartController->executeInternal());
    }