app/Customize/Controller/Block/PlazaCheckProductController.php line 45

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller\Block;
  3. use Eccube\Controller\AbstractController;
  4. use Plugin\CustomerRank42\Repository\CustomerPriceRepository;
  5. use Plugin\ProductListSaleType\Repository\PlazaRepository;
  6. use Plugin\ProductPlus42\Repository\ProductDataDetailRepository;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  10. class PlazaCheckProductController extends AbstractController {
  11.   /**
  12.    * @var ProductDataDetailRepository
  13.    */
  14.   protected $productDataDetailRepository;
  15.   /**
  16.    * @var CustomerPriceRepository
  17.    */
  18.   protected $customerPriceRepository;
  19.   /**
  20.    * @var PlazaRepository
  21.    */
  22.   protected $plazaRepository;
  23.   public function __construct(
  24.     CustomerPriceRepository $customerPriceRepository,
  25.     ProductDataDetailRepository $productDataDetailRepository,
  26.     PlazaRepository $plazaRepository
  27.   ){
  28.     $this->customerPriceRepository $customerPriceRepository;
  29.     $this->productDataDetailRepository $productDataDetailRepository;
  30.     $this->plazaRepository $plazaRepository;
  31.   }
  32.   /**
  33.    * @Route("/block/plaza_check_product", name="block_plaza_check_product")
  34.    * @Template("Block/plaza_check_product.twig")
  35.    */
  36.   public function index(Request $request)
  37.   {
  38.     // 顧客ID
  39.     $customer_id "";
  40.     // 未ログイン時は何も表示しない(EC-CUBE3と同じ仕様)
  41.     if (!$this->isGranted('ROLE_USER')) {
  42.       return [
  43.         'CheckProducts' => [],
  44.         'htPrice' => [],
  45.         'customer_id' => $customer_id,
  46.         'htNego' => [],
  47.         'htBox' => [],
  48.         'htFav' => [],
  49.         'htCFav' => [],
  50.       ];
  51.     }
  52.     // ログイン時のみ最近チェックした商品を取得
  53.     $user $this->getUser();
  54.     $customer_id $user->getId();
  55.     // 最近チェックした商品を取得(plg_pia_product_accessテーブルから)
  56.     $CheckProducts $this->plazaRepository->getRecentlyCheckedByCustomer($customer_id,8);
  57.     // 交渉可能
  58.     $htNego $this->productDataDetailRepository->getHash("7");
  59.     $htBox $this->productDataDetailRepository->getHash("28");
  60.     // 目安価格(価格0円の予約品用)
  61.     $htMeyasu $this->productDataDetailRepository->getHash("55");
  62.     // お気に入り
  63.     $htFav $this->plazaRepository->getHashFavorite();
  64.     $htCFav $this->plazaRepository->getHashCustomerFavorite($customer_id);
  65.     return [
  66.       'CheckProducts' => $CheckProducts,
  67.       'htPrice' => $this->customerPriceRepository->getHashPrice(2),
  68.       'customer_id' => $customer_id,
  69.       'htNego' => $htNego,
  70.       'htBox' => $htBox,
  71.       'htMeyasu' => $htMeyasu,
  72.       'htFav' => $htFav,
  73.       'htCFav' => $htCFav,
  74.     ];
  75.   }
  76. }