Answer the question
In order to leave comments, you need to log in
How to display additional image or icon in Opencart 3 categories?
I'm trying to display an additional category image in the category wall. Everything has already been done in the admin panel, the picture is added to the database, a new column is created with the name menu_icon.
On the category page, it turns out to display an additional image, but there is no category wall.
$data['categories'] = [];
foreach($categories as $category) {
$childs_data = [];
if(isset($category['children'])) {
foreach($category['children'] as $child) {
$childs_data[] = [
'category_id' => $child['category_id'],
'name' => $child['name'],
'href' => $this->url->link('product/category', 'path='.$category['category_id'].'_'.$child['category_id'])
];
}
}
if ($result['menu_icon']) {
$menu_icon = $this->model_tool_image->resize($category['menu_icon'], $image_width, $image_height);
} else {
$menu_icon = $this->model_tool_image->resize('placeholder.png', 100, 100);
}
if ($category['image']) {
$image = $this->model_tool_image->resize($category['image'], $image_width, $image_height);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $image_width, $image_height);
}
$data['categories'][] = [
'category_id' => $category['category_id'],
'name' => $category['name'],
'image' => $image,
'menu_icon' => $menu_icon,
'href' => $this->url->link('product/category', 'path='.$category['category_id']),
'childs' => $childs_data
];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question