开发者

magento getCollection() can we put where condition?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜