product main category_id

I am trying to modify my cart so I know what category is the main one for each product on that products page.



How can I access this value?



when I turn on debugging I can see at the smarty variable level there is the main_category variable that can be accessed within the product.tpl page using $product.main_category, but what I really want to be able to do is get at this value in the init.php page if possible.



I have done an easy work around which uses the



$category_id_from_prod_id = db_get_field(“SELECT $db_tables[products_categories].category_id FROM $db_tables[products_categories] LEFT JOIN $db_tables[categories] ON $db_tables[categories].category_id=$db_tables[products_categories].category_id WHERE $db_tables[products_categories].product_id=‘$product_id’ AND $db_tables[products_categories].link_type=‘M’ $category_condition”);



sql/function with the product_id which I can get at in the init.php page but I would rather not use this extra function if the main category id for the product should already be accessable at this point



does anyone know if there is a developers manual available as this would be very helpful and might help answer my question



thanks

J

Hey J,



I’m interested in the very same thing. I’m not that great with Smarty, but it seems like there should be an easy way to access that variable through Smarty directly. If you figure this out, please post it up here.



Thanks,



B