tags:

views:

29

answers:

0

Hello. I want to filter some configurable products by attributes that are used to create more instances of that product (size, color etc.). This means those attributes are not directly assigned to the configurable product, but their childs.

I already have a code that filters configurable products by some attributes, but these are all assigned to the main product, and the children inherit that: designer.

$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_apparel_eu',$attributes_sizes);
}
if(isset($_GET['order'])) $_productCollection->setOrder($this->getRequest()->getParam('order'), $this->getRequest()->getParam('dir'));

 $_productCollection->load();

here, the color, and size_apparel_eu, are not working, because those are not directly assigned to the product, but their children.