0

I created this file (code\local\Mage\Catalog\Block\Product\Exclusives.php) to get all product from the attribute 'online_exclusive' that is also part for a specific attribute set id.

The code works, but in (template\catalog\product\exclusives.phtml) the toolbar is returning empty. If I remove ->addAttributeToFilter('attribute_set_id', $setID) the toolbar returns a true value. I can't think of any other way to work this out. How else could I look for the attribute_set_id. This is being used as a sub category page that is displaying a static block.

{{block type="catalog/product_exclusives" name="online.exclusives" alias="online.exclusives" column_count="6" products_count="400" template="catalog/product/exclusives.phtml"}}

<?php

class Mage_Catalog_Block_Product_Exclusives extends Mage_Catalog_Block_Product_List{

   protected function _getProductCollection($setID){    
      $collection = Mage::getResourceModel('catalog/product_collection');
      $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());

      $collection = $this->_addProductAttributesAndPrices($collection)
         ->addStoreFilter()
         ->addAttributeToFilter('attribute_set_id', $setID)
         ->addAttributeToFilter('online_exclusive', true);

      $this->setProductCollection($collection);


      return $collection;
   }
   public function getLoadedProductOnlineExclusiveCollection($e){
     return $this->_getProductCollection($e);
   }
}
?>

Thanks!

  • can you post the code from your exclusives.phtml file. – Marius Jul 27 '15 at 15:47
1

I was able to fix this. I rewrote the function and extended _beforeToHtml()

protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $layer = $this->getLayer();

            $origCategory = null;

                $this->_productCollection  = Mage::getModel('catalog/category')->load(Mage::registry('current_category')->getParentCategory()->getId())
                        ->getProductCollection()
                        ->addAttributeToSelect('*')
                        ->addAttributeToFilter('online_exclusive', true)
                        ->setPageSize($this->get_prod_count())
                        ->setCurPage($this->get_cur_page());

            $this->prepareSortableFieldsByCategory($layer->getCurrentCategory());

            if ($origCategory) {
                $layer->setCurrentCategory($origCategory);
            }
        }

        return $this->_productCollection;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.