src/Eccube/Controller/TopController.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Controller;
  13. use Eccube\Controller\AbstractController;
  14. use Eccube\Repository\ProductRepository;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\Routing\Annotation\Route;
  18. class TopController extends AbstractController
  19. {
  20.     private $productRepository;
  21.     public function __construct(ProductRepository $productRepository)
  22.     {
  23.         $this->productRepository $productRepository;
  24.     }
  25.     /**
  26.      * @Route("/", name="homepage")
  27.      */
  28.     public function index(Request $request): Response
  29.     {
  30.         $searchData = array();
  31.             $qb $this->entityManager->createQueryBuilder();
  32.             $query $qb->select("plob")
  33.                 ->from("Eccube\\Entity\\Master\\ProductListOrderBy""plob")
  34.                 ->where('plob.id = :id')
  35.                 //->setParameter('id', $this->eccubeConfig['eccube_product_order_newer'])
  36.                 ->setParameter('id'4)
  37.                 ->getQuery();
  38.             $searchData['orderby'] = $query->getOneOrNullResult();
  39.             /*$cat_id = 8;
  40.             $qb = $this->entityManager->createQueryBuilder();
  41.             $query = $qb->select("ctg")
  42.                 ->from("Eccube\\Entity\\Category", "ctg")
  43.                 ->where('ctg.id = :id')
  44.                 ->setParameter('id', $cat_id)
  45.                 ->getQuery();
  46.             $searchData['category_id'] = $query->getOneOrNullResult();*/
  47.             $qb $this->productRepository->getQueryBuilderBySearchData($searchData);
  48.             $query $qb->setMaxResults(20)->getQuery();
  49.             $products $query->getResult();
  50.         return $this->render('index.twig', [
  51.             'Products' => $products,
  52.         ]);
  53.     }
  54. }