/** * {@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)))); }
/** * 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; }
/** * 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(); }