Collection是magento中很重要的功能之一,怎麼自定義對這些collection進行過濾
- "from"=>$fromValue, "to"=>$toValue
- "like"=>$likeValue
- "neq"=>$notEqualValue
- "in"=>array($inValues)
- "nin"=>array($notInValues)
- "eq"=>$equal
- "nlike"=>$notlike
- "is"=>$is
- "gt"=>$greaterthan
- "lt"=>$lessthan
- "gteq"=>$greterthanequal
- "lteq"=>$lessthanequal
- "finset"=>$unknown
- "date"=>true, "to" => $now
對應的將轉化為sql的條件
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->addFieldToFilter('entity_id', array('from'=>20, 'to'=>30))
->addFieldToFilter('name', array('like'=>'%cindy%'));