How can i access repository functions in twig template in symfony2

Viewed 16746

I have the class categroies and class Products.

In my repository i have function

getProducts($categoryid,$location)

I need to loop in twig template like this

 {% for category in categories %}
    --{{ category.name }}--
      {% for product in getProducts(category.id,location) %}
     --{{ product.name }}--
    {% endfor %}
 {% endfor %}

or is there any better way for that

4 Answers
Related