Post by sopranodesign » Fri Jan 13, 2012 7:41 am

How can I get the category ID in the feature.php controller file?

New member

Posts

Joined
Mon Dec 19, 2011 8:52 am

Post by straightlight » Fri Jan 13, 2012 8:06 am

Like this. From the XML, you may do whatever you want with the $category['category_id'] and $category['name'] from the template. ;)
Last edited by straightlight on Fri Jan 13, 2012 8:21 am, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Guru Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sopranodesign » Fri Jan 13, 2012 8:14 am

That's a very elegant solution, thanks a lot!

I found I actually need the parent category so I found another way to do it straight in the controller file (although it's much better to use XML)

I loaded the category module:

Code: Select all

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

Code: Select all

foreach ($products as $product_id) {
I added

Code: Select all

$product_cat = $this->model_catalog_product->getCategories($product_id);		
$product_cat_parent = $this->model_catalog_category->getCategory($product_cat[0]['category_id']);
echo $product_cat_parent['parent_id'];
Thanks again for the XML. Do you, by any chance, have links to tutorials on how to edit files with the XML method?

All the best,
Cris

New member

Posts

Joined
Mon Dec 19, 2011 8:52 am

Post by straightlight » Fri Jan 13, 2012 8:21 am

While your methodology instructs to edit core files, this can also be instructed by XML. In other words, you just answered your own question. ;)

I just edited my post by adding the parent XML so not to override core files.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Guru Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sopranodesign » Fri Jan 13, 2012 8:37 am

That's very cool, thanks again!

New member

Posts

Joined
Mon Dec 19, 2011 8:52 am

Post by pesof » Thu Dec 29, 2016 4:38 pm

Hi, O0
I am trying to close one payment depending on the category of the product,
I reached the payment page and i can change the $status to false and Everything should work,
What i need now is how can i get an array of the products in the cart among with their category id in order to close the payment method depending on that category id value.
Hope you guys can help.

Newbie

Posts

Joined
Thu Dec 29, 2016 4:29 pm
Who is online

Users browsing this forum: No registered users and 50 guests