开发者

magento getCollection() can we put where condition?

开发者 https://www.devze.com 2022-12-22 06:15 出处:网络
i am working on a magento project and i need to get the value according to country wise like sele开发者_JS百科ct address where country =\"Nepal\"

i am working on a magento project and i need to get the value according to country wise like sele开发者_JS百科ct address where country ="Nepal"

can we send the where condition in getCollection() function

$collection = Mage::getModel('relocator/location')->getCollection();

any help will be appreciated


got the solution ;P

Mage::getModel('relocator/location')
    ->getCollection()
    ->addFilter('country','Nepal');


You can use diffrent condition like below reference from this.

$collection = Mage::getModel('catalog/product')->getCollection();

Is Equal To

$collection->addAttributeToFilter('status', array('eq' => 1));

Greater Than

$collection->addAttributeToFilter('price', array('gt' => 3));

Contains – with % wildcards Is NULL

$collection->addAttributeToFilter('sku', array('like' => 'DVD%'));

$collection->addAttributeToFilter('entity_id', array('nin' => array(1,2,12)));

0

精彩评论

暂无评论...
验证码 换一张
取 消