app/Customize/Controller/Block/ZenTop003Controller.php line 28

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller\Block;
  3. use Eccube\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. use Eccube\Repository\ProductRepository;
  8. class ZenTop003Controller extends AbstractController
  9. {
  10.     /**
  11.      * @var ProductRepository
  12.      */
  13.     private $productRepository;
  14.     
  15.     public function __construct(
  16.         ProductRepository $productRepository
  17.     ) {
  18.         $this->productRepository $productRepository;
  19.     }
  20.     /**
  21.      * @Route("/block/zen_top003", name="block_zen_top003")
  22.      * @Template("Block/zen_top003.twig")
  23.      */
  24.     public function index(Request $request)
  25.     {
  26.         /*
  27.         =========
  28.         $limit = 10; //取得する商品数
  29.         $qb = $this->productRepository->getQueryBuilderBySearchData([]);
  30.         $qb
  31.             ->orderBy('p.create_date', 'desc')
  32.             ->setMaxResults($limit);
  33.         $Products = $qb->getQuery()->getResult();
  34.         */
  35.         $Products = array();
  36.         for ($i 1$i 11$i++) {
  37.             $criteria = ['add_item2'=>'Lanking' $i];
  38.             $temp $this->productRepository->findBy($criteria); 
  39.             foreach ($temp as $t) {
  40.                 $Products[] = $t;
  41.             }
  42.             /*
  43.             if (count($temp)) {
  44.                 $Products[] = $temp[0];
  45.             }
  46.             */
  47.         }
  48.         $connection $this->entityManager->getConnection();
  49.         $sql 'SELECT * FROM `blb_features` WHERE `view`=1 ORDER BY `order` LIMIT 5';
  50.         $stmt $connection->prepare($sql);
  51.         $result $stmt->executeQuery();
  52.         $Features $result->fetchAllAssociative();
  53.         /*
  54.         $news = array();
  55.         if (count($newsList)) {
  56.             $newsList[0]['text1'] = nl2br(url2link($newsList[0]['text1']));
  57.             if (file_exists('up_images/news/' . $newsList[0]['id'] . '/1.jpg')) {
  58.                 $newsList[0]['image'] = '../up_images/news/' . $newsList[0]['id'] . '/1.jpg';
  59.             } else {
  60.                 $newsList[0]['image'] = '';
  61.             }
  62.             $news = $newsList[0];
  63.             $category = $news['category'];
  64.         }
  65.         */
  66.         return [
  67.             'Products' => $Products,
  68.             'Features' => $Features
  69.         ];
  70.     }
  71. }