<?php
namespace App\Controller\Product;
use App\Entity\Main\Product\Product;
use App\Repository\Main\Product\ProductRepository;
use App\Repository\Main\Slider\ItemRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class ProductController extends AbstractController
{
/**
* @Route("/urunler", name="product")
*/
public function index(Request $request, ProductRepository $productRepository, ItemRepository $sliderItemRepository): Response
{
$request->query->set('locale', $request->getLocale());
$request->query->set('status_id', Product::STATUS['ACTIVE']);
$request->query->set('sort_order', 'ASC');
$request->query->set('sort_by', 'order_number');
$productPaginator = $productRepository->findByRequest($request);
$sRequest = new Request();
$sRequest->query->add([
'order_number' => 'ASC',
'slider_slug' => 'homepage',
]);
$sliderItemPaginator = $sliderItemRepository->findByRequest($sRequest);
return $this->render('product/index.html.twig', [
'productPaginator' => $productPaginator,
'sliderItemPaginator' => $sliderItemPaginator,
]);
}
}