久久久久久久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

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

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模板網(wǎng)!

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

相關文檔推薦

Magento products by categories(按類別劃分的 Magento 產(chǎn)品)
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 中跳過結帳以獲取可下載的產(chǎn)品)
主站蜘蛛池模板: 日本中文字幕在线观看 | 成人小视频在线观看 | 久久精品国产久精国产 | 成人午夜看片 | 国产精品美女久久久 | 国产精品久久久久久久久久久久午夜片 | 91视频进入 | 国产精品一区二区三区久久久 | 毛片黄片免费看 | 亚洲 欧美 日韩在线 | 97国产一区二区精品久久呦 | 日本在线综合 | 日本aⅴ中文字幕 | 久久69精品久久久久久国产越南 | 高清成人av | 91短视频网址 | 精品少妇一区二区三区在线播放 | 黄色在线 | 国产一区二区 | 亚州午夜精品 | 国产精品久久精品 | 欧美激情免费在线 | 国产精品人人做人人爽 | 久久网一区二区三区 | 日韩精品一区二区三区视频播放 | 欧美日韩综合视频 | 91国自视频 | 秋霞a级毛片在线看 | 国产第二页 | 亚洲手机视频在线 | 成人av在线播放 | 中文字幕av网 | 美女爽到呻吟久久久久 | 久久久久久久久久毛片 | 日本久久精品视频 | 欧美久久一区二区 | 午夜电影网站 | 天天躁日日躁aaaa视频 | 日韩国产精品一区二区三区 | 久久综合久久久 | 日韩欧美一区二区三区免费观看 |