Extracting Additional Product Category Ids

I have created a special offers category with associated promotion.



I can now add this category to products quickly to turn on and off promotions.



I am trying to get both product main category ids and additional category ids form the product data information. I can then use this to change the div class for the special offers category {if $cat == etc… and change the product appearance both on the product details page, search pages and category pages to display a discount icon or title color for example.



Using the following code in the product data template…



{foreach from=$product.category_ids key=cat_id item=cat} {$cat}{/foreach}



I can list all product categories when performing a product search but only the main category id is shown when products in the main product category.



Is there another string I can use to display the additional categories even when in the main category list.



Help much appreciated as I have already spent too much time on this.

[quote name='galatzo' timestamp='1400241478' post='183670']

I have created a special offers category with associated promotion.



I can now add this category to products quickly to turn on and off promotions.



I am trying to get both product main category ids and additional category ids form the product data information. I can then use this to change the div class for the special offers category {if $cat == etc… and change the product appearance both on the product details page, search pages and category pages to display a discount icon or title color for example.



Using the following code in the product data template…



{foreach from=$product.category_ids key=cat_id item=cat} {$cat}{/foreach}



I can list all product categories when performing a product search but only the main category id is shown when products in the main product category.



Is there another string I can use to display the additional categories even when in the main category list.



Help much appreciated as I have already spent too much time on this.

[/quote]



Please try the following code:



{assign var="short_product_data" value=$product.product_id|fn_get_product_data:$auth:$smarty.const.CART_LANGUAGE:'':false:false:false:false:false:false}
{foreach from=$short_product_data.category_ids key="cat_id" item="cat"}
...




Hope that helps.

eComLabs



Works perfectly, thanks very much.



Regards