Hello all,
I am currently trying to make a special sort function for a Magento category page.
I have several attributes, which I need to use for sorting:
The first attribute is named designers. This attribute is set on a configurable product.
The next attributes are named colour and size. These are not set on the configurable product itself, but on the ”simple products”, that I combine to make the configurable product.
$attributes_designers = $this->getRequest()->getParam('designers');
$attributes_colors = $this->getRequest()->getParam('color');
$attributes_sizes = $this->getRequest()->getParam('size');
$currentCategory = Mage::getModel('catalog/layer')->getCurrentCategory();
$_productCollection = $currentCategory->getProductCollection();
if(count($attributes_designers)>0 and !in_array("ALL",$attributes_designers)) {
$_productCollection->addAttributeToFilter('designer',$attributes_designers);
}
if(count($attributes_colors)>0 and !in_array("ALL",$attributes_colors)) {
$_productCollection->addAttributeToFilter('color',$attributes_colors);
}
if(count($attributes_sizes)>0 and !in_array("ALL",$attributes_sizes)) {
$_productCollection->addAttributeToFilter('size',$attributes_sizes);
}
if(isset($_GET['order'])) $_productCollection->setOrder($this->getRequest()->getParam('order'), $this->getRequest()->getParam('dir'));
$_productCollection->load();
Unfortunately I’m unable to get the attribute colour and size working, since they are not set on the configurable product, but it’s children.
Does anyone have an idea how to get this working?
Thanks in advance