Skip to content

Instantly share code, notes, and snippets.

@mzeis
Created November 9, 2013 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzeis/7385851 to your computer and use it in GitHub Desktop.
Save mzeis/7385851 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<config>
<modules>
<Emzee_Sorter>
<version>1.0.0</version>
</Emzee_Sorter>
</modules>
<global>
<models>
<emzee_sorter>
<class>Emzee_Sorter_Model</class>
</emzee_sorter>
</models>
<events>
<catalog_block_product_list_collection>
<observers>
<emzee_sorter>
<class>emzee_sorter/observer</class>
<method>catalogBlockProductListCollection</method>
</emzee_sorter>
</observers>
</catalog_block_product_list_collection>
</events>
</global>
</config>
<?xml version="1.0"?>
<config>
<modules>
<Emzee_Sorter>
<active>true</active>
<codePool>community</codePool>
<depends></depends>
</Emzee_Sorter>
</modules>
</config>
<?php
class Emzee_Sorter_Model_Observer
{
/**
* @param Varien_Event_Observer $observer
* @return Emzee_Sorter_Model_Observer
*/
public function catalogBlockProductListCollection(Varien_Event_Observer $observer)
{
$request = Mage::app()->getFrontController()->getRequest();
$action = $request->getModuleName() . '_' . $request->getControllerName() . '_' . $request->getActionName();
if ($action === 'catalogsearch_result_index' || $action === 'catalogsearch_advanced_result') {
$collection = $observer->getEvent()->getCollection();
$collection->addOrder('sort_2', Varien_Data_Collection::SORT_ORDER_DESC);
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment