0

I added this condition to my collection for adding the or condition:

$collection->addFieldToFilter(
array('city','mobile_badge'),
 array(array('eq' => $arealist),
'1'));

But it returns the wrong result. This $collection->getAllIds(); also returns the correct ids. But when I execute

$collection->getSelect();

it's gives me correct values.

0

Check your syntax for addFieldToFilter with multiple fields.

Your function should be like below:

$collection->addFieldToFilter(
    array('city', 'mobile_badge'),
    array(
        array('eq' => $arealist), 
        array('eq' => '1')
    )
)

Please refer this for better understanding.

  • Call to undefined method ::getAllIdsSql() – Qaisar Satti Jan 6 '16 at 6:52
  • Which collection are you using, custom module collection ? – Vicky Dev Jan 6 '16 at 6:59
  • yes this is custom module collection.. – Qaisar Satti Jan 6 '16 at 7:00
  • Updated my answer, please check. – Vicky Dev Jan 6 '16 at 7:12
  • no change still the same result.. – Qaisar Satti Jan 6 '16 at 7:13
0

Try this

$collection = Mage::getModel('{your_module_name}/{your_model_name}')->getCollection();
        $collection->addFieldToFilter(
            array('city','mobile_badge'),
            array(
                array('eq' => $arealist),
                array('eq' => 1)
            ));
        print_r($collection->getAllIds());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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