2016-04-11 162 views
0

我試圖在類別頁面中顯示產品模型。 我在/catalog/controller/product/category.php添加 'model'=> $result['model'] 在類別頁面中顯示產品模型opencart

$data['products'][] = array(

        'product_id' => $result['product_id'], 

        'thumb'  => $image, 
        'name'  => $result['name'], 
        'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 
        'price'  => $price, 
        'special'  => $special, 
        'tax'   => $tax, 
        'minimum'  => $result['minimum'] > 0 ? $result['minimum'] : 1, 
        'rating'  => $result['rating'], 
        'href'  => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url), 
        'model'  => $result['model'] 
       ); 

我也有編輯category.tpl與產品的foreach

<?php if (!empty($product['model'])) { ?> 
        <h5 class="model">&nbsp;<?php echo $product['model']; ?></h5> 
       <?php } ?> 

,但沒有下面的代碼顯示在類別頁面中。

我還應該做什麼?

+0

嘗試設置「模式」爲靜態文本,以測試該.tpl文件是至少能夠正確顯示 –

+0

我更換價格,名稱,並在這兩種情況下,我得到未定義指數誤差 –

+0

阿吉斯Soleas,嘗試的print_r($結果)在category.php文件中,並檢查它給模型的結果? –

回答

1

確保sql查詢包含模型字段。很多時候查詢都是特定的,並且不會返回數據庫表中的所有字段。 要做到這一點導航到catalog > model > catalog > product.php並尋找功能getProducts
編輯此功能以允許模型。

相關問題