<?php
namespace Customize\Controller\Block;
use Eccube\Controller\AbstractController;
use Plugin\CustomerRank42\Repository\CustomerPriceRepository;
use Plugin\ProductListSaleType\Repository\PlazaRepository;
use Plugin\ProductPlus42\Repository\ProductDataDetailRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class PlazaCheckProductController extends AbstractController {
/**
* @var ProductDataDetailRepository
*/
protected $productDataDetailRepository;
/**
* @var CustomerPriceRepository
*/
protected $customerPriceRepository;
/**
* @var PlazaRepository
*/
protected $plazaRepository;
public function __construct(
CustomerPriceRepository $customerPriceRepository,
ProductDataDetailRepository $productDataDetailRepository,
PlazaRepository $plazaRepository
){
$this->customerPriceRepository = $customerPriceRepository;
$this->productDataDetailRepository = $productDataDetailRepository;
$this->plazaRepository = $plazaRepository;
}
/**
* @Route("/block/plaza_check_product", name="block_plaza_check_product")
* @Template("Block/plaza_check_product.twig")
*/
public function index(Request $request)
{
// 顧客ID
$customer_id = "";
// 未ログイン時は何も表示しない(EC-CUBE3と同じ仕様)
if (!$this->isGranted('ROLE_USER')) {
return [
'CheckProducts' => [],
'htPrice' => [],
'customer_id' => $customer_id,
'htNego' => [],
'htBox' => [],
'htFav' => [],
'htCFav' => [],
];
}
// ログイン時のみ最近チェックした商品を取得
$user = $this->getUser();
$customer_id = $user->getId();
// 最近チェックした商品を取得(plg_pia_product_accessテーブルから)
$CheckProducts = $this->plazaRepository->getRecentlyCheckedByCustomer($customer_id,8);
// 交渉可能
$htNego = $this->productDataDetailRepository->getHash("7");
$htBox = $this->productDataDetailRepository->getHash("28");
// 目安価格(価格0円の予約品用)
$htMeyasu = $this->productDataDetailRepository->getHash("55");
// お気に入り
$htFav = $this->plazaRepository->getHashFavorite();
$htCFav = $this->plazaRepository->getHashCustomerFavorite($customer_id);
return [
'CheckProducts' => $CheckProducts,
'htPrice' => $this->customerPriceRepository->getHashPrice(2),
'customer_id' => $customer_id,
'htNego' => $htNego,
'htBox' => $htBox,
'htMeyasu' => $htMeyasu,
'htFav' => $htFav,
'htCFav' => $htCFav,
];
}
}