2017-02-17 24 views
2

私がバックオフィスにいて、注文を追加して顧客を検索しようとすると、小さなボックスに顧客の住所が表示されます。私が持っている/themes/default/template/controllers/orders/form.tplで AddOrder-Search for Customer screenshotPrestashop - Backoffice - Add Orderの表示アドレス

function searchCustomers() 
    { 
.......................... 
      html += '<div class="panel-heading">'+this.company+' '+this.firstname+' '+this.lastname; 
      html += '<span class="pull-right">#'+this.id_customer+'</span></div>'; 
      html += '<span>'+this.email+'</span><br/>'; 
      html += '<span>'+this.addresses+'</span><br/>'; 

しかし、私は私が何かを追加する必要があると思う 「未定義」として、それはちょうど示しcontrollers/admin/AdminCustomersController.php(searchCustomers)ですが、わかりません。

誰かが私にどのコードがないのか教えていただけますか?

私はデータを表示するにはPrestaShopの1.6.1.7

答えて

1

を使用しています、あなたはそれがありません場合は、データを取得する必要があります。この場合、this.addressは「存在しない」ため、未定義を通知します。

あなたはより多くのちょうどライン$result['addresses'] .= $address['alias'].'<br />';を変更する必要がある場合は、/ AdminCustomerControllers.php

public function ajaxProcessSearchCustomers() 
    { 
     $searches = explode(' ', Tools::getValue('customer_search')); 
     $customers = array(); 
     $searches = array_unique($searches); 
     foreach ($searches as $search) { 
      if (!empty($search) && $results = Customer::searchByName($search, 50)) { 
       foreach ($results as $result) { 
        if ($result['active']) { 
         $customer = new Customer($result['id_customer']); 
         $addresses = $customer->getAddresses($this->context->language->id); 
         $result['addresses'] = ''; 
         if(is_array($addresses) and !empty($addresses)) 
         { 
          foreach ($addresses as $address) { 
           $result['addresses'] .= $address['alias'].'<br />'; 
          } 
         } 
         $customers[$result['id_customer']] = $result; 
        } 
       } 
      } 
     } 

     if (count($customers)) { 
      $to_return = array(
       'customers' => $customers, 
       'found' => true 
      ); 
     } else { 
      $to_return = array('found' => false); 
     } 

     $this->content = Tools::jsonEncode($to_return); 
    } 

これは、アドレス(アドレスの唯一のエイリアスを定義しますオーバーライド/コントローラ/ adminにこれを使用することができます。

正しいクラスclass AdminCustomersController extends AdminCustomersControllerCoreを設定してからファイルを削除することを忘れないでください。cache/class_index.php

+0

ありがとうございました! – qqlaw

関連する問題