I've created a module that is intended to allow me to add custom sort features to my catalog pages (my product collection). For whatever reason, it returns my collection no problem but fails to honor any form of sort that I apply to it. Here is my Observer.php code
//File: app/code/local/MyExtensions/Attsetfilter/Model/Observer.php
<?php
class MyExtensions_Attsetfilter_Model_Observer
{
public function load_productsby_attributesetid($observer) {
$collection = $observer->getCollection();
$collection->addAttributeToSort('attribute_set_id', 'asc');
echo "Extension is being called";
return $collection;
}
}
I know my product collection is being passed through here because if I comment out the first line of my public function ("$collction = ...") it returns nothing. I've attempted to add filters to the function like so
$collection->addAttributeToSort('attribute_set_id', 'asc');
But it never seems to honor them. I've seen other methods of filtering a product collection such as:
$collection = $this->getCollection()
->setOrder('fieldname', 'asc')
->setOrder('fieldname2');
But that snippet won't work in my extension code either. Is there something obvious that I am doing wrong? Thanks in advance.
EDIT: Here is my modules config.xml file as well:
<?xml version="1.0"?>
<config>
<modules>
<MyExtensions_Attsetfilter>
<version>0.1.0</version>
</MyExtensions_Attsetfilter>
</modules>
<global>
<events>
<catalog_product_collection_load_after>
<observers>
<product_load_before>
<type>singleton</type>
<class>MyExtensions_Attsetfilter_Model_Observer</class>
<method>load_productsby_attributesetid</method>
</product_load_before>
</observers>
</catalog_product_collection_load_after>
</events>
<helpers>
<attsetfilter>
<class>MyExtensions_Attsetfilter_Helper</class>
</attsetfilter>
</helpers>
</global>
</config>