Opencart, how to display all categories with images on the opencart 1.5.1.3 home page

in opencart 1.5.1.3 I want to display all categories with images at the top and category name on botoom.

as soon as any click on the image or name goes to this category page.

I try my best, even I have a featured.tpl file that displays popular products on the home page, I also try to change it, but it does not work.

in featured.tpl I'm trying to change

<?php foreach ($products as $product) { ?> 

to

 <?php foreach ($categories as $category) { ?> 

but this does not work and an error is displayed

 Invalid argument supplied for foreach() 

how can i display this?

thanks

+6
source share
1 answer

You cannot just use $ categories in a tpl file, you need to assign categories for presentation using a controller

Open

/catalog/controller/module/featured.php

Find this line around line 10

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

Before you put

 $this->load->model('catalog/category'); $this->data['categories'] = $this->model_catalog_category->getCategories(0); 

And save

+9
source

Source: https://habr.com/ru/post/899319/


All Articles