3

I need to use filters on different type of product listings not just on category page.

Let me give and example i have the product listing of mostly-viewed products . I have created a CMS page and assigned it a template file say mostly-viewd.phtml. Now i want to show filters on it.

So far i did this :

I made a custom module where,

Block/List.php

    <?php
    class Company_Filter_Block_List extends Mage_Catalog_Block_Product_List
    {
        protected function _getProductCollection()
        {
        $collection = parent::_getProductCollection();

                    /* Need to work here */

        return $collection;
        }
    }

Now i am able to use this block and getting the product list of category i am using root category here so i am getting all the products of store now i want to filter them and show only those products , which have atleast 30 views.

Any idea how should i do this.

Thanks in advance.

4
  • how do you show the products in the mostly-viewd.phtml file, is it a copy of list.phtml but with a certain category id or something like that? Commented Oct 4, 2013 at 11:40
  • I think it is possible using widgets. I can't comment any further because I am still learning it..
    – Mr_Green
    Commented Oct 4, 2013 at 11:42
  • Hi Sander, yes it will be like list.phtml but the collection will be different i.e $products = Mage::getResourceModel('reports/product_collection') ->addAttributeToSelect('*') ->setStoreId($storeId) ->addStoreFilter($storeId) ->addAttributeToSelect(array('name', 'price', 'minimal_price', 'small_image')) ->addViewsCount() ->setPageSize($productCount);
    – Sarvagya
    Commented Oct 4, 2013 at 11:57
  • How are you specifying the products display block in the CMS page? ie, explain what you mean with 'I have created a CMS page and assigned it a template file'
    – ProxiBlue
    Commented Oct 8, 2013 at 15:16

1 Answer 1

1

There is no need to rewrite this block.

You can just hook into catalog_block_product_list_collection and add your filters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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