Jump to content

How to create an products array that relate to a given category?


Recommended Posts

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

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.

44400_OJZdIr7f4IujtYspM45h_t

example.zip

tpls.zip

Link to comment
Share on other sites

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

×
×
  • Create New...