php - OpenCart 2 - Show Category Title on Product Page -


i searched , found results, modules , solution open cart 1, want open cart 2.

in product.tpl

  <ul class="list-unstyled">     <?php if ($manufacturer) { ?>     <li><?php echo $text_manufacturer; ?> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a></li>     <?php } ?>     <li><?php echo $text_model; ?> <?php echo $model; ?></li>     <?php if ($reward) { ?>     <li><?php echo $text_reward; ?> <?php echo $reward; ?></li>     <?php } ?>     <li><?php echo $text_stock; ?> <?php echo $stock; ?></li>   </ul> 

i want show category title in list. not find option in admin panel decided manually. know must in product.php no idea how product name

$data['category_title'] = $this->request->get['category_title']; 

thanks in advance

pedram, website url should

index.php?route=product/product&path=20_27&product_id=41 

here path=20 → category_id

but url have not path variable because directly go throgh on search page or home page product listing. if want category title want develop code through product_id.

here code getting category title

product.php → controller file

$categories = $this->model_catalog_category->getcategoryname($this->request->get['product_id']); 

category.php → model file

public function getcategoryname($product_id) {        $query = $this->db->query("select distinct(cd.name),p2c.product_id,cd.category_id " . db_prefix . "product_to_category p2c, " . db_prefix . "category_description cd p2c.product_id = '".$product_id."' , cd.category_id = p2c.category_id , cd.category_id != 1");            return $query->rows; } 

if product select under more 1 category give array of result otherwise give 1 result.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -