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; }
protected function _beforeToHtml() { $html = ''; $entityids = $this->getData('products_sku'); if (empty($entityids)) { //return $html; } $eids = explode(',', $entityids); $idlist = array(); foreach ($eids as $eid) { if ($eid) { $idlist[] = $eid; } } $collection = Mage::getResourceModel('catalog/product_collection'); $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()); $collection = $this->_addProductAttributesAndPrices($collection)->addAttributeToFilter('SKU', array('in' => $idlist))->addStoreFilter()->setPageSize($this->getProductsCount())->setCurPage(1); $this->setProductCollection($collection); return parent::_beforeToHtml(); }