/** * Get crosssell items * * @return array */ public function getItemCollection() { if (!Mage::helper('conversionpro')->isActiveEngine() || !Mage::getStoreConfigFlag('conversionpro/crosssell_settings/upsell_enabled')) { 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 = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($id); if (empty($parentIds)) { $lastAdded = $id; break; } } } $crossSellIds = Mage::helper('conversionpro')->getSalespersonCrossSellApi()->getRecommendationsIds($lastAdded); $this->_maxItemCount = Mage::getStoreConfig('conversionpro/crosssell_settings/upsell_limit'); $this->_itemCollection = $this->_getCollection()->addAttributeToFilter('entity_id', array('in' => $crossSellIds)); } return $this->_itemCollection; }
/** * @param string $html * @param Mage_Catalog_Block_Product_List_Upsell $block * @return string */ private function _processUpsellProducts($html, $block) { $helper = $this->_getHelper(); /** @var $processor Mageplace_Callforprice_Model_Htmlprocessor_Interface */ $processor = Mage::getModel('mageplace_callforprice/htmlprocessor_factory')->createProcessor(); $processor->load($html); if ($helper->isGlobalEnabled()) { $processor->replace($helper->getCssSelector('upsell_product_price'), $helper->prepareReplacement()); return $processor->getHtml(); } $processor->process('upsell', array('products' => $block->getItemCollection())); return $processor->getHtml(); }