In Magento, there’s a column in Product Grid/Table which is Name.
It only accepts or filter the table if you put the exact word/s.
Sample is “What Happened Last Night” (just an example)
If you put “What” it will filter correctly, if you add “Happened” it will still filter correctly but if you input “What Last” it will return 0 records unless there’s a “What Last” record.
I have this code in the core itself.
$this->addColumn('name',
array(
'header'=> Mage::helper('catalog')->__('Name'),
'index' => 'name',
'filter_condition_callback' => array($this, '_customNameFilter'),
));
$store = $this->_getStore();
if ($store->getId()) {
$this->addColumn('name_search', array(
'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
'type' => 'text',
'filter_condition_callback' => array($this, '_customNameFilter'),
));
}
Based on this link, Grid filter for columns with complex values
I need to remove the index and adjust something or some files in which I’m totally lost as the author did not mention the file paths used.
Can anyone guide me on what file should I adjust or create if needed.
The Code above has the file path of
appcodecoreMageAdminhtmlBlockCatalogProductGrid.php
What other files/modules should I adjust an what lines of code should I’d be looking at to attain this result.
I could not thank you enough for assisting me.
2
Answers
Atwix example will not solve the problem you described. If you want to make a filter smart enough to be on-the-fly tokenizer you will have to split the search string by spaces and add each token to where part of the query with “OR LIKE %’.$token.’%”
Solution
you will have to rewrite Mage_Adminhtml_Block_Catalog_Product_Grid in a local Module with following xml:
and add following methods into class
And dont forget to rename Your_Module with your own namespace and add module description xml to /app/etc/modules/
you’re welcome
here is a working solution for your case
this space tokenizer filter will also work with any other grid field.