weiser78 Posted October 19, 2011 Share Posted October 19, 2011 Hi everyone. I have a question concerning categories - I'm getting their ID's on product or product list page using: {$product->id_category_default} Now when I have the ID, i would like to display different info about this category e.g. category name, description etc and I guess it should be quite simple function. Another question is for features. There is loop in product page that displays all the features for the product: {foreach from=$features item=feature} <li><span class="feature_name">{$feature.name|escape:'htmlall':'UTF-8'}:</span> {$feature.value|escape:'htmlall':'UTF-8'}</li> {/foreach} Is it possible to exclude some features from that list? Or include only few features? Link to comment Share on other sites More sharing options...
souhirfki Posted March 7, 2012 Share Posted March 7, 2012 I have the same first problem any one to help!!! Link to comment Share on other sites More sharing options...
PawelGIX Posted April 30, 2012 Share Posted April 30, 2012 Also I need this code. How to display the category name based on the {$product->id_category_default}? Link to comment Share on other sites More sharing options...
epasquazzo Posted May 7, 2012 Share Posted May 7, 2012 Hi, try using {$category->name} . Link to comment Share on other sites More sharing options...
xabe20 Posted August 20, 2012 Share Posted August 20, 2012 I have the same problem I want to display the parent category on the product page For Category ID parent, I have no problem: {$ product-> category_default} but for the category name, how to do ? Link to comment Share on other sites More sharing options...
NemoPS Posted August 24, 2012 Share Posted August 24, 2012 Hi, yes, you can display all sort of data for the default category of a product, since the category object is assigned in the product page. i did a dump of the object for the ipod nano in a test store, here are the most useful properties 8you can access them like $category->name in the template): public 'id' => int 2 public 'id_category' => string '2' (length=1) public 'name' => string 'iPods' (length=5) public 'active' => string '1' (length=1) public 'position' => string '0' (length=1) public 'description' => string 'Now that you can buy movies from the iTunes Store and sync them to your iPod, the whole world is your theater.' (length=110) public 'id_parent' => string '1' (length=1) public 'level_depth' => string '1' (length=1) public 'nleft' => string '2' (length=1) public 'nright' => string '11' (length=2) public 'link_rewrite' => string 'music-ipods' (length=11) public 'meta_title' => string '' (length=0) public 'meta_keywords' => string '' (length=0) public 'meta_description' => string '' (length=0) public 'date_add' => string '0000-00-00 00:00:00' (length=19) public 'date_upd' => string '2012-07-27 16:23:29' (length=19) public 'groupBox' => null For the features, i always put it ids or features names to exclude/inslue certain ones, like {foreach from=$features item=feature} {if feature.name == 'Coolness'} <li><span class="feature_name">{$feature.name|escape:'htmlall':'UTF-8'}:</span> {$feature.value|escape:'htmlall':'UTF-8'}</li> {/if} {/foreach} Cheers! Link to comment Share on other sites More sharing options...
Sharak Posted April 28, 2014 Share Posted April 28, 2014 (edited) Sorry for digging this topic up but it doesn't say "solved" and I have similar problem I want to get specific category information by category_id on every page, not only category or product related. No problem with link, I just use {$link->getCategoryLink('category_id')}. But how to get category name? Is there any global function for that? Edited April 29, 2014 by Sharak (see edit history) Link to comment Share on other sites More sharing options...
viper2583 Posted May 21, 2014 Share Posted May 21, 2014 hello, Go look this method in Product.php. public static function getProductCategoriesFull($id_product = '', $id_lang = null) { if (!$id_lang) $id_lang = Context::getContext()->language->id; $ret = array(); $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT cp.`id_category`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.id_category = cp.id_category) LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cp.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').') '.Shop::addSqlAssociation('category', 'c').' WHERE cp.`id_product` = '.(int)$id_product.' AND cl.`id_lang` = '.(int)$id_lang ); foreach ($row as $val) $ret[$val['id_category']] = $val; return $ret; } Link to comment Share on other sites More sharing options...
Sharak Posted May 21, 2014 Share Posted May 21, 2014 Thanks but it had been solved here http://www.prestashop.com/forums/topic/327206-creating-category-links/ 1 Link to comment Share on other sites More sharing options...
m.mira Posted September 12, 2015 Share Posted September 12, 2015 try this : $myCustomCatIDs = 20;$myCustomCats = Category::getCategoryInformations( $myCustomCatIDs ); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now