/** * Retrieve wishlist item count (include config settings) * Used in top link menu only * * @return int */ public function getItemCount() { $storedDisplayType = $this->_customerSession->getWishlistDisplayType(); $currentDisplayType = $this->scopeConfig->getValue(self::XML_PATH_WISHLIST_LINK_USE_QTY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); $storedDisplayOutOfStockProducts = $this->_customerSession->getDisplayOutOfStockProducts(); $currentDisplayOutOfStockProducts = $this->scopeConfig->getValue(self::XML_PATH_CATALOGINVENTORY_SHOW_OUT_OF_STOCK, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if (!$this->_customerSession->hasWishlistItemCount() || $currentDisplayType != $storedDisplayType || $this->_customerSession->hasDisplayOutOfStockProducts() || $currentDisplayOutOfStockProducts != $storedDisplayOutOfStockProducts) { $this->calculate(); } return $this->_customerSession->getWishlistItemCount(); }