public function viewAction(CategoryInterface $category, $slug)
{
/**
* We must check that the product slug is right. Otherwise we must
* return a Redirection 301 to the right url
*/
if ($slug !== $category->getSlug()) {
return $this->redirectToRoute('store_category_purchasables_list', ['id' => $category->getId(), 'slug' => $category->getSlug()], 301);
}
/**
* @var CategoryRepository $categoryRepository
* @var PurchasableRepository $purchasableRepository
*/
$categoryRepository = $this->get('elcodi.repository.category');
$purchasableRepository = $this->get('elcodi.repository.purchasable');
$categories = array_merge([$category], $categoryRepository->getChildrenCategories($category));
$purchasables = $purchasableRepository->getAllFromCategories($categories);
return $this->renderTemplate('Pages:category-view.html.twig', ['purchasables' => $purchasables, 'category' => $category]);
}