新しいモジュールを作成してみてください
あなたのconfig.xmlで
...
<adminhtml>
<global_search>
<magepal_custom_attributes>
<class>MagePal_GlobalAttributesSearch_Model_Search_Customattributes</class>
<acl>magepal_globalattributessearch</acl>
</magepal_custom_attributes>
</global_search>
</adminhtml>
...
app / code / local / MagePal / GlobalAttributesSearch / Model / Search / Customattributes.php
<?php
class MagePal_GlobalAttributesSearch_Model_Search_Customattributes extends Varien_Object
{
/**
* Load search results
*
*/
public function load() {
$arr = array();
$searchText = $this->getQuery();
// move code above to your if statement and do your db lookup accordingly
$collection = Mage::getModel('module/name')->getCollection()
if(is_int($searchText)){
/* search for int in product sku and custom */
$collection->addFieldToFilter(
array('field_name'),
array(
array('like'=>'%'.$searchText.'%'),
)
);
}
else{
/* search product name and description */
$collection->addFieldToFilter(
array('field_name','field_name'),
array(
array('like'=>'%'.$searchText.'%'),
array('like'=>'%'.$searchText.'%'),
)
);
}
$collection->load();
foreach ($collection as $model) {
$arr[] = array(
'id' => 'path/1/'.$model->getId(),
'type' => Mage::helper('adminhtml')->__('Custom Attributes'),
'name' => $model->getId(),
'description' => Mage::helper('core/string')->truncate('desc', 35),
'url' => Mage::helper('adminhtml')->getUrl('*/path/edit', array('id'=>$model->getId())),
);
}
$this->setResults($arr);
return $this;
}
}
http://blog.mattstephens.co.uk/post/27326981315/adding-custom-module-to-magentos-admin-global-searchを参照してください
グローバル製品検索ブロックを書き換えることもできます。