I'm trying to fetch a product collection by custom attribute:


The products will be saved in the backend with this attribute, which is a multi-select field. So there will be comma separated values like AE,ES,DK. The product will be hidden in these countries. If the user is browsing from any of these countries the product will not be displayed.

I have the current country code of user browsing from:

$current_country = 'AE';

While I'm trying to filter attribute, I cannot filter the product collection as per my requirement. I tried:

->addAttributeToFilter('hidden_countries', array('nin'=>array('finset'=>$current_country)));

Don't know how to check !finset.

Magento 1.9


Example : The database field(hidden_countries ) will hold the value as : 'AE,DK,US,ES' etc Current country based on IP address : 'DK'

i don't want to select the row(s) that have DK in the field(hidden_countries)

1 Answer 1


Try to use addAttributeToFilter with or condition

        array('finset'=> array('AF')),
        array('finset'=> array('IN')),
        array('finset'=> array('UK')),


        array('attribute'=> 'hidden_countries','finset' => array('AF')),
        array('attribute'=> 'hidden_countries','finset' => array('IN')),
        array('attribute'=> 'hidden_countries','finset' => array('UK')),
  • Pardon for my unclear question. What i actually need is like this : WHERE FIND_IN_SET('AE',hidden_countries.value) = 0
    – Shan
    Commented Aug 22, 2016 at 8:00
  • im unable to solve this problem !, what i had done so far is filtered using nlike(%$country_code%), which will work perfectly, since all the country codes are two lettered & have no duplicates
    – Shan
    Commented Aug 28, 2016 at 10:17

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.