Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Show products based on an attribute value
Jr. Member
Total Posts:  2
Joined:  2012-03-19


I have an attribute called “outlet” in each of my products with values ​​1 or 0 depending on whether it belongs to that group or not. I would be interested to create a link like mostviewed, bestseller, specialprice or New. I made the following but I\’m stuck somewhere.

First in the app / code / local / Mage / Catalog / Block / product I created a file called outlet.php with the following code (I\’ve done basing on the above):

class Mage_Catalog_Block_Product_outlet extends Mage_Catalog_Block_Product_List
function get_prod_count()
//unset any saved limits
return (isset($_REQUEST[\’limit\’])) ? intval($_REQUEST[\’limit\’]) : 9;
}// get_prod_count

function get_cur_page()
return (isset($_REQUEST[\’p\’])) ? intval($_REQUEST[\’p\’]) : 1;
}// get_cur_page

protected function _getProductCollection()

$collection = Mage::getResourceModel(\’catalog/product_collection\’)
->addAttributeToFilter(\’outlet\’, array(\’eq\’ => 1))
->addAttributeToSort(\’price\’, \’desc\’)


return $collection;
}// _getProductCollection
}// Mage_Catalog_Block_Product_Outlet

Then I created a page on the CMS with the following code in the XML:

<reference name=\"content\">
<block type=\"catalog/product_outlet\" name=\"product_outlet\" template=\"catalog/product/list.phtml\">
<action method=\"setCategoryId\"><category_id>10</category_id></action>
<action method=\"setColumnCount\"><column_count>3</column_count></action>
<action method=\"setProductsCount\"><count>0</count></action>
<block type=\"catalog/product_list_toolbar\" name=\"product_list_toolbar\" template=\"catalog/product/list/toolbar.phtml\">
<block type=\"page/html_pager\" name=\"product_list_toolbar_pager\" />
<action method=\"setDefaultGridPerPage\"><limit>9</limit></action>
<action method=\"addPagerLimit\"><mode>grid</mode><limit>9</limit></action>
<action method=\"addPagerLimit\"><mode>grid</mode><limit>15</limit></action>
<action method=\"addPagerLimit\"><mode>grid</mode><limit>30</limit></action>
<action method=\"addColumnCountLayoutDepend\"><layout>one_co lumn</layout><count>3</count></action>
<action method=\"setToolbarBlockName\"><name>product_list_to olbar</name></action>

But it does not work! Where products should appear, appears all white ...

Any idea???

Thank you.

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top