1

我想做一个如下所示的查询,以从产品集合中过滤一些产品(使用属性)。

SELECT <attributes>
FROM <tables & joins>
WHERE (<some AND conditions>) OR (<some AND conditions>) 

WHERE条件应过滤符合第一组AND条件或第二组AND条件的产品。问题是我找不到OR在多个AND条件之间添加条件的方法。任何人都可以帮助我使用 Magento 在 where 条件下编写代码addAttributeToFilter()吗?或任何其他功能?

4

1 回答 1

1

如果我正确理解你,我认为你需要做一些变化:

->addAttributeToFilter(...filter here...)
->addAttributeToFilter(array(
    array(
        'attribute' => 'special_to_date',
        'date' => true,
        'from' => $dateTomorrow
    ),
    array(
        'attribute' => 'special_to_date',
        'null' => 1
    )
));

这将是:

...filter here... AND (special_to_date >= '2012-07-03' OR special_to_date IS NULL)...

于 2014-09-29T17:44:25.860 回答