Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareLayout()
 {
     $this->setId('customerViewAccordion');
     $this->addItem('lastOrders', array('title' => __('Recent Orders'), 'ajax' => true, 'content_url' => $this->getUrl('customer/*/lastOrders', array('_current' => true))));
     $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
     $customer = $this->getCustomer($customerId);
     $websiteIds = $this->_shareConfig->getSharedWebsiteIds($customer->getWebsiteId());
     // add shopping cart block of each website
     foreach ($websiteIds as $websiteId) {
         $website = $this->_storeManager->getWebsite($websiteId);
         // count cart items
         $cartItemsCount = $this->_quoteFactory->create()->setWebsite($website)->loadByCustomer($customerId)->getItemsCollection(false)->addFieldToFilter('parent_item_id', array('null' => true))->getSize();
         // prepare title for cart
         $title = __('Shopping Cart - %1 item(s)', $cartItemsCount);
         if (count($websiteIds) > 1) {
             $title = __('Shopping Cart of %1 - %2 item(s)', $website->getName(), $cartItemsCount);
         }
         // add cart ajax accordion
         $this->addItem('shopingCart' . $websiteId, array('title' => $title, 'ajax' => true, 'content_url' => $this->getUrl('customer/*/viewCart', array('_current' => true, 'website_id' => $websiteId))));
     }
     // count wishlist items
     $wishlistCount = $this->_itemsFactory->create()->addCustomerIdFilter($customerId)->addStoreData()->getSize();
     // add wishlist ajax accordion
     $this->addItem('wishlist', array('title' => __('Wishlist - %1 item(s)', $wishlistCount), 'ajax' => true, 'content_url' => $this->getUrl('customer/*/viewWishlist', array('_current' => true))));
 }
Exemplo n.º 2
0
 /**
  * Retrieve wishlist item collection
  *
  * @return \Magento\Wishlist\Model\Resource\Item\Collection
  */
 public function getItemCollection()
 {
     if ($this->_itemCollection === null) {
         $this->_itemCollection = $this->_wishlistCollectionFactory->create()->addWishlistFilter($this)->addStoreFilter($this->getSharedStoreIds())->setVisibilityFilter();
     }
     return $this->_itemCollection;
 }
Exemplo n.º 3
0
 /**
  * @param int|\Magento\Wishlist\Model\Item|\PHPUnit_Framework_MockObject_MockObject $itemId
  * @param \Magento\Framework\Object $buyRequest
  * @param null|array|\Magento\Framework\Object $param
  * @throws \Magento\Framework\Exception\LocalizedException
  *
  * @dataProvider updateItemDataProvider
  */
 public function testUpdateItem($itemId, $buyRequest, $param)
 {
     $storeId = 1;
     $productId = 1;
     $stores = [(new \Magento\Framework\Object())->setId($storeId)];
     $newItem = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->getMock();
     $newItem->expects($this->any())->method('setProductId')->will($this->returnSelf());
     $newItem->expects($this->any())->method('setWishlistId')->will($this->returnSelf());
     $newItem->expects($this->any())->method('setStoreId')->will($this->returnSelf());
     $newItem->expects($this->any())->method('setOptions')->will($this->returnSelf());
     $newItem->expects($this->any())->method('setProduct')->will($this->returnSelf());
     $newItem->expects($this->any())->method('setQty')->will($this->returnSelf());
     $newItem->expects($this->any())->method('getItem')->will($this->returnValue(2));
     $this->itemFactory->expects($this->once())->method('create')->will($this->returnValue($newItem));
     $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue($stores));
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($stores[0]));
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $product->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $product->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId));
     $instanceType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\AbstractType')->disableOriginalConstructor()->getMock();
     $instanceType->expects($this->once())->method('processConfiguration')->will($this->returnValue($this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock()));
     $newProduct = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $newProduct->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $newProduct->expects($this->once())->method('getTypeInstance')->will($this->returnValue($instanceType));
     $item = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->getMock();
     $item->expects($this->once())->method('getProduct')->will($this->returnValue($product));
     $items = $this->getMockBuilder('Magento\\Wishlist\\Model\\Resource\\Item\\Collection')->disableOriginalConstructor()->getMock();
     $items->expects($this->once())->method('addWishlistFilter')->will($this->returnSelf());
     $items->expects($this->once())->method('addStoreFilter')->will($this->returnSelf());
     $items->expects($this->once())->method('setVisibilityFilter')->will($this->returnSelf());
     $items->expects($this->once())->method('getItemById')->will($this->returnValue($item));
     $items->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$item])));
     $this->itemsFactory->expects($this->any())->method('create')->will($this->returnValue($items));
     $this->productRepository->expects($this->once())->method('getById')->with($productId, false, $storeId)->will($this->returnValue($newProduct));
     $this->assertInstanceOf('Magento\\Wishlist\\Model\\Wishlist', $this->wishlist->updateItem($itemId, $buyRequest, $param));
 }
Exemplo n.º 4
0
 /**
  * Prepare collection.
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     $collection = $this->_collectionFactory->create()->addCustomerIdFilter($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID))->addDaysInWishlist()->addStoreData()->setInStockFilter(true);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }