Monday, 7 July 2014

Get Current Category in opencart


Get Current Category in opencart

if(isset($this->request->get['path'])) {
    $path = $this->request->get['path'];
    $cats = explode('_', $path);
    $cat_id = $cats[count($cats) - 1];
}
echo $cat_id;

4 comments:

Anonymous said...

It's works! Thanks!!

Anonymous said...

Thanks for help! It really works.

Anonymous said...

Hi,

I get this following error when i open a product via latest module.

Notice: Undefined variable: cat_id in/var/www/vhosts/shop/catalog/view/theme/default/template/product/product.tplon line 282

I get this error I guess because there is no path ID in the URL when products are opened via latest module.

Could you please tell me ow to fix this??

PHP Coder said...

Yes there is no path id in the URL so condition return false