Post by ocmatt » Sat May 27, 2017 3:19 am

For the "refine your search" option in the parent category, I want to also add pictures so that the customers can click on the picture in the parent category that will direct them to the subcategory. How should I do this?

Newbie

Posts

Joined
Sat May 27, 2017 3:16 am

Post by chrisranjana.com » Mon May 29, 2017 10:44 pm

ocmatt wrote:
Sat May 27, 2017 3:19 am
...I want to also add pictures so that the customers can click on the picture in the parent category that will direct them to the subcategory. How should I do this?
In file /catalog/controller/product/category.php change lines 184 to 189

from

Code: Select all

	$product_total = $this->model_catalog_product->getTotalProducts($data);				

				$this->data['categories'][] = array(
					'name'  => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
					'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
				);
to

Code: Select all

$product_total = $this->model_catalog_product->getTotalProducts($data);				
                $category_info = $this->model_catalog_category->getCategory($result['category_id']);
				$this->data['categories'][] = array(
					'name'  => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
					'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
					'image' => $category_info['image'],
				);
then in the template file

catalog/view/theme/default/template/product/category.tpl you could use the variable

$categories[$i]['image']

(or)

$category['image']

to show the category image.
If a category does not have an image you will receive errors !

Chris, Opencart Developers and Programmers,
Opencart Developers Opencart Programmers
https://www.chrisranjana.com


User avatar
Active Member

Posts

Joined
Thu Feb 26, 2009 2:23 am
Location - chennai, India
Who is online

Users browsing this forum: Google [Bot] and 162 guests