VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: studioblue on June 15, 2013, 00:13:13 AM

Title: [Solved] Category ID with category Name in product create tab?
Post by: studioblue on June 15, 2013, 00:13:13 AM
VM 2.012b
Joomla 2.5

I was wondering if, in the product information Tab where you select a category, can it also show the category id.  Just not great at php so I am not sure how to get the category-id to show after the category name.
I see in the code where the category_tree is being called but I am not sure if the id is available.?


Thanks,
Bobby


[attachment cleanup by admin]
Title: Re: Category ID with category Name in product create tab?
Post by: studioblue on June 15, 2013, 17:23:08 PM
I see the ids in the option values but I need them to show for the client after the name of the category.  See attached.

[attachment cleanup by admin]
Title: Re: Category ID with category Name in product create tab?
Post by: studioblue on June 15, 2013, 19:30:18 PM
HERE is the solution, thanks to PRO for the light bulb in the dark.
Thanks for your help, PRO.

in administrator/components/com_virtuemart/helpers/shopfunctions.php

Where your code above says:

} else {

                  $categoryTree .= '<option ' . $selected . ' ' . $disabled . ' value="' . $childId . '">';

                  $categoryTree .= str_repeat (' - ', ($level - 1));



                  $categoryTree .= $category->category_name . '</option>';

               }

REPLACE WITH

} else {

                  $categoryTree .= '<option ' . $selected . ' ' . $disabled . ' value="' . $childId . '">';

                  $categoryTree .= str_repeat (' - ', ($level - 1));



                  $categoryTree .= $category->category_name . "-" . $childId .'</option>';

               }

works like a charm!
Title: Re: [Solved] Category ID with category Name in product create tab?
Post by: Milbo on June 17, 2013, 08:55:22 AM
Yeh it would be intersting to add to your code a perm check, so that only admins see it.
Title: Re: [Solved] Category ID with category Name in product create tab?
Post by: studioblue on June 18, 2013, 14:00:39 PM
Hey Milbo thanks for the reply,
I placed this in this file.

administrator/components/com_virtuemart/helpers/shopfunctions.php

It's not showing in the frontend at this point so I think that the perm check is not necessary.

Thanks,

Bobby