/** * Get crosssell items * * @return array */ public function getItemCollection() { if (!$this->helper->isActiveEngine() || !$this->helper->isUpsellEnabled()) { return parent::getItemCollection(); } $items = $this->_items; if (is_null($items)) { reset($this->_itemCollection); $lastAdded = null; //This code path covers the 2 cases - product page and shopping cart if ($this->getProduct() != null) { $lastAdded = $this->getProduct()->getId(); } else { $cartProductIds = $this->_getCartProductIds(); $lastAdded = null; for ($i = count($cartProductIds) - 1; $i >= 0; $i--) { $id = $cartProductIds[$i]; $parentIds = $this->_confModel->getParentIdsByChild($id); if (empty($parentIds)) { $lastAdded = $id; break; } } } $crossSellIds = $this->crossSellHelper->getRecommendationsIds($lastAdded); $this->_maxItemCount = $this->helper->getCrosssellLimit(); $this->_itemCollection = $this->_getCollection()->addAttributeToFilter('entity_id', array('in' => $crossSellIds)); } return $this->_itemCollection; }
/** * {@inheritdoc} */ public function getItemCollection() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getItemCollection'); if (!$pluginInfo) { return parent::getItemCollection(); } else { return $this->___callPlugins('getItemCollection', func_get_args(), $pluginInfo); } }