Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Product API - Multiselect Attribute
 
bcelenza
Member
 
Avatar
Total Posts:  44
Joined:  2008-08-27
 

Posted this earlier, but I dont think I was very clear. Let’s start simple…

Using the product API, how can I add a filter for an attribute that is multi-select?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mosses Akizian
Sr. Member
 
Avatar
Total Posts:  176
Joined:  2009-04-28
Los Angeles, CA
 

I don’t need the API for now, but were you able to figure this out? I’ve been trying to filter with a multi-select attribute also, but keep running into issues. Standard filters (name, price, etc.) are just working fine.

Works fine:

$model Mage::getModel('catalog/product');
    
$collection $model->getCollection();
    
$collection->addAttributeToSelect('name'); // lists okay
    
$collection->addAttributeToFilter('attribute',123)); // dummy filter
    
$collection->load();

Get blank page

$model Mage::getModel('catalog/product');
    
$collection $model->getCollection();
    
$collection->addAttributeToSelect('multi-select-attribute'); // throws blank page
    
$collection->addAttributeToFilter('attribute',123)); // dummy filter
    
$collection->load();

I’m guessing there’s a simple workaround to this. Appreciate if anyone can figure this out.

Happy New Year!

 
Magento Community Magento Community
Magento Community
Magento Community
 
SF9
Sr. Member
 
Avatar
Total Posts:  127
Joined:  2008-07-03
Cork, Ireland
 

I was looking for an answer to this question and ultimately found an answer

$products->addAttributeToFilter($filter, array(\"like\"=>\"%\".$value.\"%\"));
 
Magento Community Magento Community
Magento Community
Magento Community
 
Polo Magento
Jr. Member
 
Total Posts:  21
Joined:  2008-12-11
 

This solution wan’t work.

If you want to find id = 56
u will filter 56, AND 156, AND 256… etc

 
Magento Community Magento Community
Magento Community
Magento Community
 
Polo Magento
Jr. Member
 
Total Posts:  21
Joined:  2008-12-11
 

i think using ‘finset’ instead of “like” is better, seems to work

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top