2017-09-15 86 views

回答

0

請注意,製造商可以有多個地址。此代碼只能從首地址獲取國家/地區。

覆蓋控制器ProductControlleroverride/controllers/front

class ProductController extends ProductControllerCore 
{ 
    public function initContent() 
    { 
     parent::initContent(); 

     if (!$this->errors) { 
      $manufacturer = new Manufacturer((int)$this->product->id_manufacturer, $this->context->language->id); 
      $manufacturerAddress = $manufacturer->getAddresses($this->context->language->id); 

      if (isset($manufacturerAddress) && $manufacturerAddress[0]['country']) { 
       $this->context->smarty->assign(array(
        'manufacturer_country' => $manufacturerAddress[0]['country'], 
       )); 
      } 
     } 
    } 
} 

而在你的TPL打印:

{$manufacturer_country|escape:'html':'UTF-8'} 

記得刪除cache/class_index.php當你重寫控制器。

相關問題