I've got a very strange problem. I created a custom attribute named "taille_ecran" which mean in english "screen size". The labels of this attribute are numbers like 1.2, 1.6, 2, 5, 6, etc...

When I try to add a custom filter like this :


The filter filters by the option_id of thoses labels in "taille_ecran" instead of labels values. In fact, here is the ID of my labels :

31 => 1.2 41 => 5 etc...

When I tried to get the labels "lteq" under 7 there is no result and when I try 35 I get 1 result which is 1.2.

I try also to print this value in my products list :

echo $_product->getTailleEcran();

// print 31 when it's for 1.2...

It's very hard for me to explain clearly what is happening. I don't have this problem with other attribute.

Thanks in advance for your help !

3 Answers 3


Try this:

$attribute = Mage::getSingleton('catalog/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'taille_ecran');
$source = $attribute->getSource();
$optionId = $source->getOptionId($_GET['max_size']);
$_productCollection->addAttributeToFilter('taille_ecran', array('lteq'=>$optionId));
  • Still the same problem. To complete the description of this issue. I'am in list.phtml and I've create a custom product's filter. I added this on top of the file : $_productCollection=$this->getLoadedProductCollection(); $_productCollection->clear(); Dec 24, 2013 at 10:59
  • Actually, my original answer was wrong. Now edited. $_productCollection->clear() will remove all items in the collection, which is not what you want. So, you should remove that.
    – kiatng
    Dec 25, 2013 at 16:16

What you want to achieve is not supported by magento. Option filters are based on the option id, this means you are not able to filter by the value.

If you want this, you have to create your own attribute, add it as decimal and have your own source model with value = key, so you still have a select in the backend but you can filter by the value.


Thanks to Fabian and Kiatng here is what I've done to solve this issue. I created a new custom attribute and beside using Drop Down I used Price.

That's permit me to not change my source code and now it's working.

Hope it'll help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.