久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Magento addFieldToFilter:兩個字段,匹配為 OR,而不是

Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND)
本文介紹了Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

過去幾個小時我一直在堅持這個.我通過修改 /lib/Varien/Data/Collection/Db.php 中的幾行來讓它工作,但我更愿意使用正確的解決方案并保持我的核心不變.

I've been stuck on this for the last few hours. I got it working by hacking a few lines in /lib/Varien/Data/Collection/Db.php, but I'd rather use the proper solution and leave my core untouched.

我需要做的就是獲取一個集合并按兩個或多個字段對其進行過濾.比如說,customer_firstnameremote_ip.這是我的(沒有破解 Db.php 的功能)代碼:

All I need to do is get a collection and filter it by two or more fields. Say, customer_firstname and remote_ip. Here's my (disfunctional without hacking Db.php) code:

$collection = Mage::getModel('sales/order')->getCollection()->
addAttributeToSelect("*")->
addFieldToFilter(array(array('remote_ip', array('eq'=>'127.0.0.1')),
array('customer_firstname', array('eq'=>'gabe'))), array('eq'=>array(1,2,3)));

使用股票 Db.php,我嘗試了這個:(樣本取自 http://magentoexpert.blogspot.com/2009/12/retrieve-products-with-specific.html)

With a stock Db.php, I tried this: (sample taken from http://magentoexpert.blogspot.com/2009/12/retrieve-products-with-specific.html)

$collection->addFieldToFilter(array(
    array('name'=>'orig_price','eq'=>'Widget A'),
    array('name'=>'orig_price','eq'=>'Widget B'),           
));

但這給了我這個錯誤:

Warning: Illegal offset type in isset or empty  in magento/lib/Varien/Data/Collection/Db.php on line 369

如果我用 try/catch 包裝它,那么它會進入 _getConditionSql() 并給出這個錯誤:

If I wrap that with a try/catch, then it moves into _getConditionSql() and gives this error:

Warning: Invalid argument supplied for foreach()  in magento/lib/Varien/Data/Collection/Db.php on line 412

有沒有人有任何可以執行此操作的有效代碼?我正在運行 Magento 1.9(企業).謝謝!

Does anyone have any working, functional code for doing this? I'm running Magento 1.9 (Enterprise). Thanks!

推薦答案

我有另一種方法可以在字段中添加條件:

I've got another way to add an or condition in the field:

->addFieldToFilter(
    array('title', 'content'),
    array(
        array('like'=>'%$titlesearchtext%'), 
        array('like'=>'%$contentsearchtext%')
    )
)

這篇關于Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Magento products by categories(按類別劃分的 Magento 產品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊事件?)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯誤 404在 Magento 管理員登錄頁面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
Skip Checkout in Magento for a downloadable product(在 Magento 中跳過結帳以獲取可下載的產品)
主站蜘蛛池模板: 99久久精品国产一区二区三区 | 成年人视频免费在线观看 | av手机免费在线观看 | 国产成人99久久亚洲综合精品 | 久久中文字幕在线 | 国产成人精品免费视频大全最热 | 日韩成人免费 | 在线看免费的a | 99久久久久国产精品免费 | 亚洲精品国产第一综合99久久 | 国产精品精品视频一区二区三区 | 91综合在线观看 | 五月激情婷婷六月 | 久久久久www | 九色在线观看 | 日韩精品免费一区二区在线观看 | 韩日一区二区三区 | 国产在线精品一区二区三区 | 午夜日韩| 成人免费视频网站在线观看 | 密色视频 | 久久精品中文字幕 | 久久久久久成人网 | 国产精品久久久久久久久久久久久久 | 久在线| 日韩资源| 亚洲字幕在线观看 | 国产一区二区在线免费观看 | 日本中文字幕在线视频 | 国产精品欧美一区二区三区不卡 | 色综合天天天天做夜夜夜夜做 | 在线成人免费观看 | 久久久精 | 一区二区在线免费观看 | 亚洲精品成人av | 久久免费观看一级毛片 | 亚洲成人av一区二区 | 欧美精品一区二区三区蜜臀 | 中文字幕第二区 | 亚洲3p| 久久美女视频 |