本文介紹了Magento 集合中的 addAttributeToFilter 和 OR 條件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想根據不同屬性的幾個標準來選擇產品.
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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!