protected function _beforeToHtml() { parent::_beforeToHtml(); if (!($template = $this->getTemplate())) { $this->setTemplate($this->defaultTemplate); } $collection =& $this->getProductCollection(); if ($this->getProductSource() == 'product') { // product if ($ids = $this->getProductIds()) { $ids = preg_split('#[\\s|,]+#', $ids, -1, PREG_SPLIT_NO_EMPTY); $ids = array_map('intval', $ids); $ids = array_unique($ids); $collection->addIdFilter($ids); } } else { // catalog $category_ids = $this->getProductCategory() ? $this->getProductCategory() : ''; $category_ids = preg_split('#[\\s|,]+#', $category_ids, -1, PREG_SPLIT_NO_EMPTY); $category_ids = array_map('intval', $category_ids); $category_ids = array_unique($category_ids); $this->_addCategoryFilter($collection, $category_ids); // var_dump($category_ids); } $numProducts = $this->getProductLimitation() > 0 ? intval($this->product_limitation) : 0; $collection->setPage(1, $numProducts); $collection->load(); return $this; }
/** * Retrieve how much products should be displayed. * * @return int */ public function getProductsCount() { if (!$this->hasData('products_count')) { return parent::getProductsCount(); } return $this->_getData('products_count'); }
public function _prepareLayout() { $FeaturedStatus = Mage::getStoreConfig('sm_featured/sm_featured/enable'); if ($FeaturedStatus == 1) { Mage::app()->getLayout()->getBlock('head')->addItem('skin_css', 'css/slider/lib/idangerous.swiper.css'); $this->getLayout()->getBlock('head')->addItem('skin_js', 'js/slider/lib/idangerous.swiper.js'); } return parent::_prepareLayout(); }
public function testToHtml() { $this->assertEmpty($this->_block->getProductCollection()); $this->_block->setProductsCount(5); $this->_block->setTemplate('product/widget/new/content/new_list.phtml'); $this->_block->setLayout(new Mage_Core_Model_Layout()); $html = $this->_block->toHtml(); $this->assertNotEmpty($html); $this->assertContains('New Product', $html); $this->assertInstanceOf('Mage_Catalog_Model_Resource_Product_Collection', $this->_block->getProductCollection()); }
protected function _toHtml() { $_productCollection = $this->getProductCollection(); if ($_productCollection && $_productCollection->getSize()) { $magicToolboxHelper = Mage::helper('magiczoomplus/settings'); $tool = $magicToolboxHelper->loadTool('category'); if (!$tool->params->checkValue('use-effect-on-category-page', 'No')) { $contents = parent::_toHtml(); require $magicToolboxHelper->getMagicToolboxListTemplateFilename(); return $contents; } } return parent::_toHtml(); }
protected function _toHtml() { $_productCollection = $this->getProductCollection(); if ($_productCollection && $_productCollection->getSize()) { $magicToolboxHelper = Mage::helper('magiczoomplus/settings'); $tool = $magicToolboxHelper->loadTool('newproductsblock'); if (!$tool->params->checkValue('enable-effect', 'No')) { $contents = parent::_toHtml(); $group = 'newproductsblock'; require Mage::getSingleton('core/design_package')->getTemplateFilename('magiczoomplus' . DS . 'magictoolbox_list.phtml'); return $contents; } } return parent::_toHtml(); }
/** * Produces html * * @return string */ protected function _toHtml() { $productIds = Mage::getModel('productblock/featuredcatalogproduct')->getCollection(); $columns = $this->getData('columns'); $title = $this->getData('Title'); $_add_to_link = $this->getData('add_to_link'); $products_count = $this->getData('products_count') ? $this->getData('products_count') : parent::getProductsCount(); //$product = Mage::getModel('catalog/product'); $pIds = array(); foreach ($productIds as $pId) { $pIds[] = $pId->getEntityId(); } $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('entity_id', array('in' => $pIds)); //->getSelect() $this->assign('_columnCount', $columns); $this->assign('_title', $title); $this->assign('_add_to_link', $_add_to_link); $this->assign('_products', $collection); return parent::_toHtml(); }
/** * Get tags array for saving cache * * @return array */ public function getCacheTags() { /* get Magento's standard cache key info */ $cacheTags = parent::getCacheTags(); return array_unique($this->_getDispatcherHelper()->dispatchEvent('catalog_product_new_get_cache_tags', $cacheTags, 'cache_tags')); }
/** * @param string $html * @param Mage_Catalog_Block_Product_New $block * @return string */ private function _processNewProducts($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('new_product_price'), $helper->prepareReplacement()); $processor->remove($helper->getCssSelector('new_product_addtocart')); return $processor->getHtml(); } $processor->process('new', array('products' => $block->getProductCollection())); return $processor->getHtml(); }