Re: Subcatagory
Posted: Wed Jan 20, 2010 3:42 pm
thanks! it works!
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Hi!Qphoria wrote:Try this:
Change:To:Code: Select all
$children = $this->getCategories($result['category_id'], $new_path);
Code: Select all
if (substr_count($new_path, '_') < 1) { $children = $this->getCategories($result['category_id'], $new_path); }
Hi Q,Qphoria wrote:all categories work with SEO for me.. even 4 levels deep
Thanks Hagelslaghagelslag wrote:Q, it even works perfect with your multiple cat block module!!
Great.
Hello, I had same problem too now. I was looking into it for some minutes and I think I figured it out. I am using OC just one day lol, but I hope it will work, try it:hagelslag wrote: Hi Q,
How do you do that?
As soon as i use a SEO keyword for a product, the breadcrumb and Category module links are lost as soon as you click that product.
I have set up an example with 2 products here:
http://bit.ly/cpuD61
One product with an SEO keyword, and one without. As you can see, if you click the left one, the subcat. closes and the subcat in the breadcrumb padth too.
Any idea why?
Thanks in advance!
Code: Select all
if ($category_id == $result['category_id']) {
$children = $this->getCategories($result['category_id'], $new_path);
}
Code: Select all
if ($category_id == $result['category_id']) {
$children = $this->getCategories($result['category_id'], $new_path);
}elseif(substr_count($new_path, '_') < 1){
array_unshift( $this->path, $category_id );
$children = $this->getCategories($result['category_id'], $new_path);
}
Code: Select all
<?php
class ControllerModuleCategory extends Controller {
protected function index() {
$this->language->load('module/category');
$this->data['heading_title'] = $this->language->get('heading_title');
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = array();
}
if (isset($parts[0])) {
$this->data['category_id'] = $parts[0];
} else {
$this->data['category_id'] = 0;
}
if (isset($parts[1])) {
$this->data['child_id'] = $parts[1];
} else {
$this->data['child_id'] = 0;
}
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ' (' . $product_total . ')',
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
$data = array(
'filter_category_id' => $category['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
$this->data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'] . ' (' . $product_total . ')',
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/category.tpl';
} else {
$this->template = 'default/template/module/category.tpl';
}
$this->render();
}
}
?>
Code: Select all
.box-category > ul > li ul {
display: none;
}
Code: Select all
.box-category > ul > li ul {
/*display: none;*/
}
It works very well. but I need a little more such as:grongor wrote: Hello, I had same problem too now. I was looking into it for some minutes and I think I figured it out. I am using OC just one day lol, but I hope it will work, try it:
Instead of lines ~55-57Use thisCode: Select all
if ($category_id == $result['category_id']) { $children = $this->getCategories($result['category_id'], $new_path); }
If you find an bug, please tell meCode: Select all
if ($category_id == $result['category_id']) { $children = $this->getCategories($result['category_id'], $new_path); }elseif(substr_count($new_path, '_') < 1){ array_unshift( $this->path, $category_id ); $children = $this->getCategories($result['category_id'], $new_path); }
Code: Select all
if($sisters) {
foreach ($sisters as $sisterMember) {
Code: Select all
if(count($sisters) > 1) {
foreach ($sisters as $sisterMember) {