Code: Select all
'cat_id' => $this->request->get['path'],
Code: Select all
'cat_id' => $this->request->get['path'],
Code: Select all
$this->load->model('catalog/product');
Code: Select all
$this->load->model('catalog/category');
Code: Select all
$this->load->model('tool/image');
Code: Select all
if (isset($this->request->get['path'])) {
$path = '';
$parts = explode('_', (string)$this->request->get['path']);
$category_id = (int)array_pop($parts);
foreach ($parts as $path_id) {
if (!$path) {
$path = $path_id;
} else {
$path .= '_' . $path_id;
}
$category_info = $this->model_catalog_category->getCategory($path_id);
if ($category_info) {
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('product/category', 'path=' . $path)
);
}
}
// Set the last category breadcrumb
$category_info = $this->model_catalog_category->getCategory($category_id);
if ($category_info) {
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
);
}
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I tried something like that but it didn't work, I think I made some mistake because I have Journal theme which works a bit differently, I used this file to print product attributes in special module as you can see in the last string and tried to get category id, attributes worked but category didn't, can you plz look where I must add your code? I tried to add it after line 16, 17 and 298, nothing worked. Also added category.php in which I could get id on line 208.straightlight wrote: ↑Fri Jun 12, 2020 7:46 pmYou could see how it's done in your catalog/controller/product/product.php file.
Code: Select all
$categories = $this->model_catalog_product->getCategories($result['product_id']);
if($categories){
$categories_info = $this->model_catalog_category->getCategory($categories[0]['category_id']);
$id = $categories_info['category_id'];
}else{
$id = '';
}
That's because you're using the first constant category ID of those products which is not what my original post states. What it does is it tracks the first category of the top or parent category ID of the depth position where the user clicked on from the breadcrumb and so forth.MrBrain wrote: ↑Sat Jun 13, 2020 2:27 amI did it much simpler, just added:Code: Select all
$categories = $this->model_catalog_product->getCategories($result['product_id']); if($categories){ $categories_info = $this->model_catalog_category->getCategory($categories[0]['category_id']); $id = $categories_info['category_id']; }else{ $id = ''; }
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: No registered users and 12 guests