dazfx Posted May 2, 2011 Share Posted May 2, 2011 How to create an products array that relate to a given category?I need to output several categories on a page(not home)I think that i have somehow to fill that array before output in my tamlate: somecode {foreach from=$products item=product name=type} ... {/foreach} I think I should use the following version: $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 50)); But, where i have to fill that array with products and how?Thanks! Link to comment Share on other sites More sharing options...
tomerg3 Posted May 2, 2011 Share Posted May 2, 2011 You post is not very clear.Are you looking to get a list of all products in a given category, or a list of categories?Perhaps a real example from your site may help. Link to comment Share on other sites More sharing options...
dazfx Posted May 2, 2011 Author Share Posted May 2, 2011 I'll try to explain more detailed.Shop consists of 6 showcases. Each showcase is looks like showcase on the attached screenshot and consists of few category of products placed in the jquery carousel.I wont to understand, how i can output products of few categories on one page in that view which i need. example.zip tpls.zip Link to comment Share on other sites More sharing options...
tomerg3 Posted May 4, 2011 Share Posted May 4, 2011 What version of Prestashop are you using?Which module are you trying to display these categories / products in? Link to comment Share on other sites More sharing options...
dazfx Posted May 5, 2011 Author Share Posted May 5, 2011 I'm using 1.4.1 version.The problem is solved.It might be useful for someone.Function(I inserted the code in the class\Product.php): function smarty_function_myprod($params, &$smarty) { global $smarty, $cookie; $category = new Category($params['cat'], intval($params['cookie']->id_lang)); $products = $category->getProducts($params['cookie']->id_lang, 1, 1, 'position', 'ASC', false, true, true, 4); $smarty->assign(array("myproducts" => $products)); } Using:In your template just add {myprod cat= category_id} before cycle wich outputs products parameters.Example(in product-list.tpl): {myprod cat=3} {foreach from=$myproducts item=product name=type} {$product.manufacturer_name} {$product.name} ... {/foreach} It fills array $myproducts by products of category with id=3.Thanks! And sorry for my English=) Link to comment Share on other sites More sharing options...
Recommended Posts