当我们在Magento中查询一条记录时, 能用filter函数来缩小结果查询范围,相对于数据库中where子句.
基础filter使用EQUAL操作和AND操作,例如,查询产品Where子句: type=simple AND set=39
Example:
<urn:catalogProductList soapenv:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<sessionId xsi:type=”xsd:string”>c9f1ca71de1da4202c84bf90f6df51cf</sessionId>
<filters xsi:type=”urn:filters”>
<filter xsi:type=”urn:associativeArray” soapenc:arrayType=”urn:associativeEntity[]“>
<item>
<key>type</key>
<value>simple</value>
</item>
<item>
<key>set</key>
<value>39</value>
</item>
</filter>
</filters>
<storeView xsi:type=”xsd:string”></storeView>
</urn:catalogProductList>
使用复合高级过滤器complex filter能完成更复杂的查询语句
例如, 查询顾客customers用了两个复合过滤器complex filters:
store_id=0 AND created_at>2012-05-13 06:11:00
Example:
<urn:customerCustomerList soapenv:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<sessionId xsi:type=”xsd:string”>c9f1ca71de1da4202c84bf90f6df51cf</sessionId>
<filters xsi:type=”urn:filters”>
<complex_filter xsi:type=”urn:complexFilterArray” soapenc:arrayType=”urn:complexFilter[]“>
<item>
<key>store_id</key>
<value>
<key>eq</key>
<value>0</value>
</value>
</item>
<item>
<key>created_at</key>
<value>
<key>gt</key>
<value>2012-05-13 06:11:00</value>
</value>
</item>
</complex_filter>
</filters>
</urn:customerCustomerList>
重点:complex filter还能用其他的语句AND操作,例如: eq (equals)等于, neq (not equals)不等于, gt (greater than)大于,
lt (less than)小于, 等等还有:
from | returns rows that are after this value (datetime only) |
to | returns rows that are before this value (datetime only) |
eq | returns rows equal to this value |
neq | returns rows not equal to this value |
like | returns rows that match this value (with % as a wildcard) |
nlike | returns rows that do not match this value (with % as a wildcard) |
in | returns rows where the value is in this array (pass an array in) |
nin | returns rows where the value is not in this array (pass an array in) |
is | unsure |
null | returns rows that are null |
notnull | returns rows that are not null |
moreq | unsure |
gt | returns rows greater than this value |
lt | returns rows less than this value |
gteq | returns rows greater than or equal to this value |
lteq | returns rows less than or equal to this value |
finset | unsure |