Post by Flysan » Sun Jul 07, 2019 6:02 am

How to get the categories list in the featured module in OC 2.3.0.2?

New member

Posts

Joined
Tue Apr 28, 2015 6:25 pm

Post by straightlight » Sun Jul 07, 2019 7:10 am

While you may have now posted in the right forum section, I do have a Bestseller with Customer Search on my namespace but is only for the master branch version on Github Opencart. Take a look at this post: viewtopic.php?f=24&t=210586#p749515 .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Flysan » Mon Jul 08, 2019 12:51 am

I found a possible solution on the internet that I want to share here.

In the controller file catalog/controller/extension/module/featured.php
After:

Code: Select all

$this->load->model('catalog/product');
Add:

Code: Select all

$this->load->model('catalog/category');
After:

Code: Select all

$product_info = $this->model_catalog_product->getProduct($product_id);
Add:

Code: Select all

$category = $this->model_catalog_product->getCategories($product_id);
				if ($category) {
					$category_array = $this->model_catalog_category->getCategory(end($category)['category_id']);
				}
After:

Code: Select all

'name'        => $product_info['name'],
Add:

Code: Select all

'category'    => $category_array['name'],
In the template file catalog/view/theme/YOUR-THEME/template/extension/module/featured.tpl
After:

Code: Select all

<div class="caption">
Add:

Code: Select all

<p><?php echo $product['category']; ?></p>

New member

Posts

Joined
Tue Apr 28, 2015 6:25 pm
Who is online

Users browsing this forum: No registered users and 45 guests