Skip to content

Instantly share code, notes, and snippets.

@forshariq
Created June 12, 2011 05:07
Show Gist options
  • Save forshariq/1021274 to your computer and use it in GitHub Desktop.
Save forshariq/1021274 to your computer and use it in GitHub Desktop.
Override Core Modules Mage/Catalog/Block/Product/List.php
<?xml version="1.0"?>
<config>
<global>
<blocks>
<catalog>
<rewrite>
<product_list>MyCompany_Catalog_Product_List</product_list>
</rewrite>
</catalog>
</blocks>
</global>
</config>
<?php
class MyCompany_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List{
/*override this function*/
protected function _getProductCollection(){
/*Add below line to add existing line of code to display stock in descending order*/
$this->_productCollection = $layer->getProductCollection()->addAttributeToSort('created_at','DESC');
}
?>
<?xml version="1.0"?>
<config>
<modules>
<MyCompany_Catalog>
<active>true</active>
<codePool>local</codePool>
</MyCompany_Catalog>
</modules>
</config>
@j0hj0h
Copy link

j0hj0h commented Mar 21, 2014

There is a Block missing in config.xml – must be:

<product_list>MyCompany_Catalog_Block_Product_List</product_list>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment