Magento模型集合常用过滤条件
Magento的MVC模式为大家所熟悉,其中的Model作为数据处理的模型,其集合中的方法是大家开发时必不可少的。最近,我总结了下Magento模型集合中的addFieldToFilter常用过滤条件,希望对大家的开发起到一定的帮助作用。
//Equals: eq
$_products->addAttributeToFilter('status', array('eq' => 1));
//Not Equals - neq
$_products->addAttributeToFilter('sku', array('neq' => 'test-product'));
//Like - like
$_products->addAttributeToFilter('sku', array('like' => 'UX%'));
//Not Like - nlike
$_products->addAttributeToFilter('sku', array('nlike' => 'err-prod%'));
//In - in
$_products->addAttributeToFilter('id', array('in' => array(1,4,98)));
//Not In - nin
$_products->addAttributeToFilter('id', array('nin' => array(1,4,98)));
//NULL - null
$_products->addAttributeToFilter('description', 'null');
//Not NULL - notnull
$_products->addAttributeToFilter('description', 'notnull');
//Greater Than - gt
$_products->addAttributeToFilter('id', array('gt' => 5));
//Less Than - lt
$_products->addAttributeToFilter('id', array('lt' => 5));
//Greater Than or Equals To- gteq
$_products->addAttributeToFilter('id', array('gteq' => 5));
//Less Than or Equals To - lteq
$_products->addAttributeToFilter('id', array('lteq' => 5));
版权声明:本站内容源自互联网,如有内容侵犯了你的权益,请联系删除相关内容。
上一篇:magento修改后台密码 下一篇:用magento布局给特定CMS页面添加静态块