2012-07-27 194 views
0

在Magento管理菜單下客戶 - >管理客戶,如果字符串包含多個單詞,我們無法使用他的名字搜索客戶。我在哪裏可以找到執行此任務的核心代碼?我們沒有此部分的擴展程序。問題的Magento:如何修復客戶姓名搜索

例子:

如果我要搜索名爲John Smith客戶,搜索「約翰·史密斯」不返回任何結果。搜索「john」或「smith」可以單獨使用,但它會顯示任何包含「john」或「smith」的名稱,類似於SQL查詢LIKE %john%LIKE %smith%

回答

1

看起來你正在使用的Magento版本1.6

像這是一個錯誤,並已被固定在1.7

下面是需要修改的代碼:應用程序/代碼/核心/法師/客戶/型號/資源/客戶/ Collection.php

我從發佈1.7版所採取的代碼:

Mage_Customer_Model_Resource_Customer_Collection  

    public function addNameToSelect() 
    { 
     $fields = array(); 
     $customerAccount = Mage::getConfig()->getFieldset('customer_account'); 
     foreach ($customerAccount as $code => $node) { 
      if ($node->is('name')) { 
       $fields[$code] = $code; 
      } 
     } 

     $adapter = $this->getConnection(); 
     $concatenate = array(); 
     if (isset($fields['prefix'])) { 
      $concatenate[] = $adapter->getCheckSql(
       '{{prefix}} IS NOT NULL AND {{prefix}} != \'\'', 
       $adapter->getConcatSql(array('LTRIM(RTRIM({{prefix}}))', '\' \'')), 
       '\'\''); 
     } 
     $concatenate[] = 'LTRIM(RTRIM({{firstname}}))'; 
     $concatenate[] = '\' \''; 
     if (isset($fields['middlename'])) { 
      $concatenate[] = $adapter->getCheckSql(
       '{{middlename}} IS NOT NULL AND {{middlename}} != \'\'', 
       $adapter->getConcatSql(array('LTRIM(RTRIM({{middlename}}))', '\' \'')), 
       '\'\''); 
     } 
     $concatenate[] = 'LTRIM(RTRIM({{lastname}}))'; 
     if (isset($fields['suffix'])) { 
      $concatenate[] = $adapter 
        ->getCheckSql('{{suffix}} IS NOT NULL AND {{suffix}} != \'\'', 
       $adapter->getConcatSql(array('\' \'', 'LTRIM(RTRIM({{suffix}}))')), 
       '\'\''); 
     } 

     $nameExpr = $adapter->getConcatSql($concatenate); 

     $this->addExpressionAttributeToSelect('name', $nameExpr, $fields); 

     return $this; 
    }