<?php
namespace Customize\Controller\Block;
use Eccube\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Eccube\Repository\ProductRepository;
class ZenTop003Controller extends AbstractController
{
/**
* @var ProductRepository
*/
private $productRepository;
public function __construct(
ProductRepository $productRepository
) {
$this->productRepository = $productRepository;
}
/**
* @Route("/block/zen_top003", name="block_zen_top003")
* @Template("Block/zen_top003.twig")
*/
public function index(Request $request)
{
/*
=========
$limit = 10; //取得する商品数
$qb = $this->productRepository->getQueryBuilderBySearchData([]);
$qb
->orderBy('p.create_date', 'desc')
->setMaxResults($limit);
$Products = $qb->getQuery()->getResult();
*/
$Products = array();
for ($i = 1; $i < 11; $i++) {
$criteria = ['add_item2'=>'Lanking' . $i];
$temp = $this->productRepository->findBy($criteria);
foreach ($temp as $t) {
$Products[] = $t;
}
/*
if (count($temp)) {
$Products[] = $temp[0];
}
*/
}
$connection = $this->entityManager->getConnection();
$sql = 'SELECT * FROM `blb_features` WHERE `view`=1 ORDER BY `order` LIMIT 5';
$stmt = $connection->prepare($sql);
$result = $stmt->executeQuery();
$Features = $result->fetchAllAssociative();
/*
$news = array();
if (count($newsList)) {
$newsList[0]['text1'] = nl2br(url2link($newsList[0]['text1']));
if (file_exists('up_images/news/' . $newsList[0]['id'] . '/1.jpg')) {
$newsList[0]['image'] = '../up_images/news/' . $newsList[0]['id'] . '/1.jpg';
} else {
$newsList[0]['image'] = '';
}
$news = $newsList[0];
$category = $news['category'];
}
*/
return [
'Products' => $Products,
'Features' => $Features
];
}
}