我想根据不同属性的几个标准来选择产品.
I'd like to select products depending on several criteria from different attribute.
我知道如何使用 $collection->addAttributeToFilter('someattribute', array('like' => '%'));
但我想为 OR 条件使用多个属性.
But I'd like to use several attribute for OR condition.
喜欢:
$collection->addAttributeToFilter('someattribute', array('like' => 'value'));`
或
$collection->addAttributeToFilter('otherattribute', array('like' => 'value'));`
获取someattribute"或otherattribute"设置为value"的产品
To get products which either 'someattribute' OR 'otherattribute' set to 'value'
有可能吗?
是的.
$collection->addAttributeToFilter(
array(
array('attribute' => 'someattribute', 'like' => 'value'),
array('attribute' => 'otherattribute', 'like' => 'value'),
array('attribute' => 'anotherattribute', 'like' => 'value'),
)
);
这篇关于Magento 集合中的 addAttributeToFilter 和 OR 条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
覆盖 Magento 配置Override Magento Config(覆盖 Magento 配置)
什么会导致 print_r 和/或 var_dump 调试变量失败?What would cause a print_r and/or a var_dump to fail debugging a variable?(什么会导致 print_r 和/或 var_dump 调试变量失败?)
如何在 magento 中以编程方式更新自定义选项?How to update custom options programatically in magento?(如何在 magento 中以编程方式更新自定义选项?)
管理页面上的 Magento 404Magento 404 on Admin Page(管理页面上的 Magento 404)
Magento - 从订单中获取价格规则Magento - get price rules from order(Magento - 从订单中获取价格规则)
Magento 更改产品页面标题以包含属性Magento Change Product Page Titles to Include Attributes(Magento 更改产品页面标题以包含属性)