Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:34:41+00:00 2026-06-10T14:34:41+00:00

I’m working for a client who owns a Magento-based store. It’s chock full of

  • 0

I’m working for a client who owns a Magento-based store. It’s chock full of products, but the names of said products are a bit messy. He did not stick to one naming convention but used different conventions throughout the years. So whenever he looks up something using the Name filter in the Admin -> Manage Products section, the results leave a lot to be desired.

So I was wondering if there’s a way to make the filtering algorithm a bit more lax, specifically in regards to word order. Because if you have a product with a name like ‘word1 word2 word3‘ and you search ‘word1 word3‘ that products doesn’t appear in the results.

Any hint would be appreciated. Cheers!

AUG 28 UPDATE: My search led me to the class *Mage_Adminhtml_Block_Widget_Grid*, and more precisely to its protected method *_addColumnFilterToCollection()*. In here you have the $cond variable, which if you print out it gives you something like this:

Array ([like] => Zend_Db_Expr Object([_expression:protected] => ‘%search term%’ ))

Here if I could intercept that search term and make it into ‘%search%term%‘ before it gets submitted to the *Zend_Db_Expr* object I’d probably solve my problem. So, any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:34:42+00:00Added an answer on June 10, 2026 at 2:34 pm

    OK, here’s a solution for this problem. Please note I have not tested this too much, just on my local test magento. So problems may arise.

    Our work class is Mage_Adminhtml_Block_Widget_Grid, found in ‘app/code/core/Mage/Adminhtml/Block/Widget/Grid.php’. You should copy this file in ‘app/code/local/Mage/Adminhtml/Block/Widget/Grid.php’, as to not overwrite core classes.

    Now, in that file go to the function named _addColumnFilterToCollection. In here, delete everything inside the ‘} else {‘ statement and replace with:

    $cond = $column->getFilter()->getCondition();
    if ($field == "name" && isset($cond)) {
    $filterOrig = $cond['like'];
    $filterReplaced = str_replace(" ", "%", $filterOrig);
    $newZendDbExpr = new Zend_Db_Expr($filterReplaced);
    $modifCond = array('like'=>$newZendDbExpr);
    $this->getCollection()->addFieldToFilter($field , $modifCond);
    } else if ($field && isset($cond)) {
    $this->getCollection()->addFieldToFilter($field , $cond);
    }
    

    The ‘$cond’ variable is the key here. If you print it you get something like:

    Array([like] => Zend_Db_Expr Object([_expression:protected] => '%filter term%'));
    

    That code snippet basically intercepts the filter term that’s passed to the Zend_Db_Expr object, passes it through a str_replace() to replace any whitespace with a ‘%’ wildcard and then sends it back to the object.

    So now if you have a product with a name like ‘word1 word2 word3’ and search filter by term ‘word1 word3’ you will get proper results. I am open to suggestions, this might not be the best approach. I’ll update after properly testing this. Cheers!

    SEP 06 UPDATE: Well, after some live testing, results are good and exactly what I wanted when. It seems there is no negative performance impact either.

    And the interesting fact is that this little modification applies to filtering in every place where you have a product grid in the admin interface (for example when creating a new order manually and you click Add Products, or in the Manage Categories -> whatever category -> Category Products tab)

    SEP 06 UPDATE 2: There is an issue. If you’re in the Orders grids and try to filter by status it throws an error. I need to make this filter only apply to the Name field. Any ideas?

    SEP 06 UPDATE 3: I revised the script to only apply to the Name field of Product grids. Now there are no conflicts with filter products by visibility or orders by status etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.