/** * Get crosssell items * * @return array */ public function getItems() { if (count(parent::getItems())) { return parent::getItems(); } $items = $this->getData('items'); if (is_null($items) || is_array($items) && !count($items)) { $items = array(); $showDefaultProducts = Mage::getStoreConfig('catalog/crosssell/show_default_products'); if ($showDefaultProducts) { $defaultProducts = trim(Mage::getStoreConfig('catalog/crosssell/default_products')); $defaultProducts = preg_replace('/\\s+/', '', $defaultProducts); if ($defaultProducts) { $defaultProducts = explode(',', $defaultProducts); if (count($defaultProducts)) { $randomOrder = Mage::getStoreConfig('catalog/crosssell/show_random'); $collection = $this->_getDefaultCollection($defaultProducts, $randomOrder); foreach ($collection as $item) { $items[] = $item; } } } } $this->setData('items', $items); } return $items; }
/** * Get crosssell items * * @return array */ public function getItems() { if (!Mage::helper('conversionpro')->isActiveEngine() || !Mage::getStoreConfigFlag('conversionpro/crosssell_settings/crosssell_enabled')) { return parent::getItems(); } $items = $this->getData('items'); if (is_null($items)) { $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/crosssell_limit'); $items = $this->_getCollection()->addAttributeToFilter('entity_id', array('in' => $crossSellIds)); } $this->setData('items', $items); $this->_itemCollection = $items; return $items; }
protected function _getCartProductIds() { if ($id = Mage::app()->getRequest()->getParams('product')) { return $id; } else { return parent::_getCartProductIds(); } }
protected function _getCartProductIds() { if ($id = Mage::app()->getRequest()->getParams('product') && $this->getRequest()->getRouteName() != 'checkout') { return $id; } else { return parent::_getCartProductIds(); } }
public function getAddToCartUrl($product, $additional = array()) { if (Mage::helper('flycart')->isActivated() && Mage::getStoreConfig('flycart/qtyupdate/crosssell')) { if (!isset($additional['_escape'])) { $additional['_escape'] = true; } $additional['_query']['flycart_item'] = $product->getId(); $additional['_query']['flycart_crosssell'] = 1; } return parent::getAddToCartUrl($product, $additional); }