So the knp bundle works fine with paginating my products, however when it comes to sorting I am not getting any errors, but the products just wont sort.
<th{% if pagination.isSorted('a.price') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Price/Lowest', 'a.price') }}</th>
So when I am trying to sort, I don't get any errors, the response is 200 and the URL changes with this:
?sort=a.pc&direction=asc&page=1
But the products are not sorted. Is this some kind of a bug? The documentation isn't very clear with the sorting stuff, but I don't think I am doing something wrong..
Here is the price field:
/**
* @ORM\Column(name="price", type="decimal", precision=10, scale=2, nullable=true)
*/
private $price;
P.S. Sorting doesn't work with other parameters too, not only price..
The action:
public function newProductsAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$products = $em->getRepository('MpShopBundle:Product')->findBy(array('status' => 1), array('id' => 'ASC'), 15);
$locale = $this->get('translator')->getLocale();
$session = $this->getRequest()->getSession();
$cart = $session->get('cart', array());
$skin = $em->getRepository('MpShopBundle:Skin')->findOneBy(array('status' => 1));
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$products,
$request->query->getInt('page', 1)/*page number*/,
9/*limit per page*/
);