app/Customize/Controller/PageController.php line 879

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 Customize\Controller;
  13. use Customize\Controller\LM\LmAbstractController;
  14. use Customize\Entity\CacheTrait;
  15. use Customize\Service\CategoryService;
  16. use Customize\Service\GoodsService;
  17. use Customize\Service\LmHelper;
  18. use Customize\Service\PageService;
  19. use Eccube\Common\Constant;
  20. use Lm\Engine\EC\Entity\CategoryWithRelated;
  21. use Customize\Service\MobileDetector as LmMobileDetector;
  22. use Symfony\Component\Cache\CacheItem;
  23. use Symfony\Component\HttpFoundation\Request;
  24. use Symfony\Component\HttpFoundation\Response;
  25. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  26. use Symfony\Component\Routing\Annotation\Route;
  27. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  28. use Lm\Service\Db\SqlService;
  29. use Customize\Service\CommonService;
  30. use Customize\Converter\DynamicConverter;
  31. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  32. use Eccube\Common\EccubeConfig;
  33. class PageController extends LmAbstractController
  34. {
  35.     use CacheTrait;
  36.     const PREFIX_CACHE "PAGE_CONTROLLER_";
  37.     const MAIN_CATEGORY_GROUPS_UNABLE_SHOW = [7,8];
  38.     /**
  39.      * @var LmMobileDetector $MobileDetector
  40.      */
  41.     protected $MobileDetector;
  42.     protected $dynamicConverter;
  43.     protected $session;
  44.     protected $CategoryService;
  45.     protected $GoodsService;
  46.     /**
  47.      * @var EccubeConfig
  48.      */
  49.     protected $eccubeConfig;
  50.     private $cacheLifeTime;
  51.     public function __construct(CommonService    $commonService,
  52.                                 LmHelper         $lmHelper,
  53.                                 LmMobileDetector $mobileDetector,
  54.                                 DynamicConverter $dynamicConverter,
  55.                                 SessionInterface $session,
  56.                                 EccubeConfig     $eccubeConfig,
  57.                                 CategoryService  $categoryService,
  58.                                 GoodsService     $goodService
  59.     ) {
  60.         //
  61.         parent::__construct($commonService$lmHelper);
  62.         //
  63.         $this->MobileDetector $mobileDetector;
  64.         $this->dynamicConverter $dynamicConverter;
  65.         $this->session $session;
  66.         $this->eccubeConfig $eccubeConfig;
  67.         $this->CategoryService $categoryService;
  68.         $this->GoodsService $goodService;
  69.         $this->cacheLifeTime $this->eccubeConfig->get("eccube_result_cache_lifetime") ?? Constant::ONE_HOUR;
  70.     }
  71.     /**
  72.      * @param Request $request
  73.      * #Route("/page/{mc}", requirements={"mc" = "\w+"}, name="page/main-category", methods={"GET"})
  74.      * @Template("Page/sub-category.twig")
  75.      */
  76.     protected function _mainCategory(Request $request$mc$mcMc null)
  77.     {
  78.         //
  79.         $request->attributes->set('_route''page/main-category');
  80.         $request->attributes->set('mc'$mc);
  81.         $request->attributes->set('mcMc'$mcMc);
  82.         //
  83.         return $this->newCategory($request$mcnull$mcMc, function ($category) use ($request$mc$mcMc) {
  84.             //
  85.             return $this->__mainCategory($request$category$mc$mcMc);
  86.         });
  87.     }
  88.     protected function __mainCategory(Request $requestCategoryWithRelated $category$mc$mcMc null)
  89.     {
  90.         //
  91.         $sql = new SqlService();
  92.         //
  93.         $data $sql->Table('landmark01.main_category_table')
  94.             ->Set('main_category_webname'$mc)
  95.             ->Find();
  96.         // モバイルの判定
  97.         $isMobile $this->MobileDetector->isMobile();
  98.         # Author Description Keyword Robots MetaTags
  99.         $Metatage = ['Author' => 'ああああ''Description' => 'いいい'];
  100.         // $this->CommonService->WriteYml(['hoge' => 'piyo'], 'hogehoge.yml');
  101.         //
  102.         $review $this->dynamicConverter->getReview(nullfalse$data['main_category_id']);
  103.         $columnList = [
  104.             [
  105.                 'uri' => '/',
  106.                 'column_custom_url' => '/custom_url',
  107.                 'main_category_webname' => 'work',
  108.                 'column_webname' => 'sagyogi-fashionable',
  109.                 'column_related_image_filename' => 'kanren.jpg  ',
  110.                 'column_related_image_alt' => 'ユニフォーム通販TOP',
  111.                 'column_name' => 'ユニフォーム通販TOP',
  112.                 'column_related_link_text' => 'ユニフォーム通販TOP',
  113.                 'column_h1_tag' => 'ユニフォーム通販TOP'
  114.             ],
  115.             [
  116.                 'uri' => '/',
  117.                 'column_custom_url' => '/custom_url',
  118.                 'main_category_webname' => 'work',
  119.                 'column_webname' => 'sagyogi-fashionable',
  120.                 'column_related_image_filename' => 'kanren.jpg  ',
  121.                 'column_related_image_alt' => 'ユニフォーム通販TOP',
  122.                 'column_name' => 'ユニフォーム通販TOP',
  123.                 'column_related_link_text' => 'ユニフォーム通販TOP',
  124.                 'column_h1_tag' => 'ユニフォーム通販TOP'
  125.             ]
  126.         ];
  127.         $upperColumnData $this->dynamicConverter->getByCategoryWebName(1$mc);
  128.         // TODO: canonicalMcDataを取得
  129.         $canonicalMcData null;
  130.         $categoryData $this->dynamicConverter->getMainCategoryName($mc);
  131.         $categoryData['main_category'] = $data;
  132.         $categoryData $this->dynamicConverter->getMainCategoryName($mc);
  133.         if (!empty($data['main_category_main_category'])) {
  134.             $subCategoryList $this->dynamicConverter->getSubCategoryList($data['main_category_main_category']);
  135.         } else if (isset($categoryData) && intval($categoryData['category_group_only_main']) == 1) {
  136.             $subCategoryList = [];
  137.         } else {
  138.             $subCategoryList $this->dynamicConverter->getSubCategoryList($data['main_category_id']);
  139.         }
  140.         $BreadCrumbs = [
  141. //            [
  142. //                'label' => $data['main_category_main_category_name'],
  143. //                'href' => "/{$data['main_category_main_category_webname']}",
  144. //            ],
  145.             [
  146.                 'label' => $data['main_category_name'],
  147.                 'href' => "{$data['main_category_main_category_webname']}/{$data['main_category_webname']}",
  148.             ],
  149. //            [
  150. //                'label' => $categoryData['category_name'],
  151. //                'href' => "/{$data['main_category_main_category_webname']}/{$data['main_category_webname']}/{$categoryData['category_webname']}",
  152. //            ],
  153.         ];
  154.         $mcMcName $mc;
  155.         $mcName $mc;
  156.         $ctName 'allItem';
  157.         $ctId 'allitem';
  158.         $mcId $data['main_category_id'];
  159.         $orderType $this->session->has('order_type') ? $this->session->get('order_type') : $request->get('type');
  160.         $display_item_count_list $this->CommonService->GetYaml('DisplayItem.yaml');
  161.         $displayMax $this->session->has('display_max') ? intval($this->session->get('display_max')) : intval($request->get('disp'));
  162.         if ($displayMax == $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW']) {
  163.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW'];
  164.         } else if ($displayMax == $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH']) {
  165.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH'];
  166.         } else if ($displayMax == $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT']) {
  167.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT'];
  168.         } else {
  169.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT'];
  170.         }
  171.         $dataItem "";
  172.         $dataItem $this->_getDataItem($request$mcId$ctId$mcName$ctName$max_display_cnt$item_count); // data['item']
  173.         $detailData = array();
  174.         $detailData['item_count'] = $item_count;
  175. //        $detailData['item_count'] = count($dataItem);
  176.         $detailData['item'] = $dataItem;
  177.         //var_dump($detailData['item']);
  178.         $detailData['pager_pages_current_num'] = 0;
  179.         $detailData['col_count'] = $isMobile 3;
  180.         $detailData['max_display_cnt'] = $max_display_cnt;
  181.         if (!empty($request->get('no')) && intval($request->get('no')) > 0) {
  182.             $detailData['min_cnt'] = min((intval($request->get('no')) + 1), $detailData['item_count']);
  183.         } else {
  184.             $detailData['min_cnt'] = min(1$detailData['item_count']);
  185.         }
  186.         $detailData['max_cnt'] = min($detailData['min_cnt'] + $detailData['max_display_cnt'] - 1$detailData['item_count']);
  187.         for ($i 1$i <= $detailData['item_count']; $i += $detailData['max_display_cnt']) {
  188.             if ($detailData['min_cnt'] >= $i and $detailData['max_cnt'] <= ($i $detailData['max_display_cnt'])) {
  189.                 $detailData['pager_pages_current_num'] = intval($i $detailData['max_display_cnt']) + 1;
  190.             }
  191.         }
  192.         $an_sort = array();
  193.         for ($i 0$i $detailData['item_count']; $i++) {
  194.             $an_sort["$i"] = $i;
  195.         }
  196.         $i 0;
  197.         foreach ($an_sort as $k => $v) {
  198.             // $an_v[$i] = $k;
  199.             $an_v[$i] = $i;
  200.             $i++;
  201.         }
  202.         $detailData['an_v'] = $an_sort;
  203.         $main_category_url2_content $isMobile && $data['main_category_url2_sp_content'] != '' $data['main_category_url2_sp_content'] : ($data['main_category_url2_content'] ?? '');
  204.         $main_category_url2_content2 $isMobile && $data['main_category_url2_sp_content2'] != '' $data['main_category_url2_sp_content2'] : ($data['main_category_url2_content2'] ?? '');
  205.         $main_category_url2_content3 $isMobile && $data['main_category_url2_sp_content3'] != '' $data['main_category_url2_sp_content3'] : ($data['main_category_url2_content3'] ?? '');
  206.         $main_category_url2_content4 $isMobile && $data['main_category_url2_sp_content4'] != '' $data['main_category_url2_sp_content4'] : ($data['main_category_url2_content4'] ?? '');
  207.         $main_category_url2_content5 $isMobile && $data['main_category_url2_sp_content5'] != '' $data['main_category_url2_sp_content5'] : ($data['main_category_url2_content5'] ?? '');
  208.         $main_category_url2_content6 $isMobile && $data['main_category_url2_sp_content6'] != '' $data['main_category_url2_sp_content6'] : ($data['main_category_url2_content6'] ?? '');
  209.         $main_category_url2_content7 $isMobile && $data['main_category_url2_sp_content7'] != '' $data['main_category_url2_sp_content7'] : ($data['main_category_url2_content7'] ?? '');
  210.         $main_category_url2_content8 $isMobile && $data['main_category_url2_sp_content8'] != '' $data['main_category_url2_sp_content8'] : ($data['main_category_url2_content8'] ?? '');
  211.         $main_category_url2_content9 $isMobile && $data['main_category_url2_sp_content9'] != '' $data['main_category_url2_sp_content9'] : ($data['main_category_url2_content9'] ?? '');
  212.         $main_category_url2_content10 $isMobile && $data['main_category_url2_sp_content10'] != '' $data['main_category_url2_sp_content10'] : ($data['main_category_url2_content10'] ?? '');
  213.         $main_category_url2_content11 $isMobile && $data['main_category_url2_sp_content11'] != '' $data['main_category_url2_sp_content11'] : ($data['main_category_url2_content11'] ?? '');
  214.         $main_category_url2_content12 $isMobile && $data['main_category_url2_sp_content12'] != '' $data['main_category_url2_sp_content12'] : ($data['main_category_url2_content12'] ?? '');
  215.         // TODO: content2を取得
  216.         $content2 '';
  217.         // TODO: content3を取得
  218.         $content3 '';
  219.         //TODO: 「関連するページ」リンクの表示
  220.         $isItemSeriesCategory 1;
  221.         $isNoDisplayDbCategory 0;
  222.         $detailItemCount 1;
  223.         $categoryGroupNoshowdb 0;
  224.         $breakCountForRankLabel 1;
  225.         $useItemUrlDuplicated false;
  226.         $mainCategoryData = array();
  227.         $main_h3 $data['main_h3_tag'];
  228.         $main_breadcrumb $data['main_breadcrumb'];
  229.         // TODO: category_h3を取得
  230.         $category_h3 '';
  231.         // TODO: category_h1を取得
  232.         $category_h1 '';
  233.         if ($categoryData['category_name'] == "全商品") {
  234.             $seoKeyword $seoKeywordTDK $categoryData['main_category_name'] . " " $categoryData['category_name'];
  235.         } elseif (in_array($data['main_category_name'], array("メディカルウェア""エステユニフォーム"))) { // パターンA
  236.             $seoKeyword $categoryData['category_name'];
  237.             $seoKeywordTDK $categoryData['category_name'] . "(" $data['main_category_name'] . ")";
  238.         } elseif (in_array($data['main_category_name'], array("作業服・作業着""作業服バートル""医療白衣""エプロン""防寒服""スタッフジャンパー""シャツ""ポロシャツ"))) { // パターンB
  239.             $seoKeyword $seoKeywordTDK $categoryData['category_name'];
  240.         } else { // パターンC
  241.             $seoKeyword $seoKeywordTDK $data['main_category_name'] . " " $categoryData['category_name'];
  242.         }
  243.         $useRecommendedItemOrder $this->dynamicConverter->useUnItemOrder($data['main_category_id']);
  244.         if ($mcMc) {
  245.             $custom_menu $this->dynamicConverter->getMainCategoryMenu($mcMc);
  246.         } else {
  247.             $custom_menu $this->dynamicConverter->getMainCategoryMenu($mc);
  248.         }
  249.         $custom_frequently_searched_word $this->dynamicConverter->getSearchWordGroup($this->eccubeConfig['EditSpMenu']['MENU_NAME_COMMON'], $this->eccubeConfig['EditSpMenu']['BOOL_TRUE']);
  250.         $common_header_contents null;
  251.         $recentviews = [];
  252.         $isMainCategory true;
  253.         // TODO: ⑧【LM】商品一覧
  254.         $is_no_display_db_category false;
  255.         $showItemDb true;
  256.         $useCache false;
  257.         $canonical_category_name '';
  258.         $average = array();
  259.         $pager_data $this->CategoryService->getPagerData(
  260.             $category->getCanonicalMainCategoryWebname(),
  261.             $ctName,
  262.             $detailData['max_display_cnt'],
  263.             $detailData['item_count'],
  264.             $detailData['min_cnt'],
  265.             $detailData['max_cnt'],
  266.             $displayMax,
  267.             $orderType,
  268.             $isMobile
  269.         );
  270.         // TODO: ⑨【LM】カテゴリ絞り込み(SP)
  271.         $isMainOnly false;
  272.         $canonicalSubCategoryList = [];
  273.         $leftmenuForCategoryData = [];
  274.         $canonicalMcName $mcName;
  275.         $items array_values(array_map(function($subCategory) {
  276.            return [
  277.                'category_id' => $subCategory['category_id'] ?? null,
  278.                'category_name' => $subCategory['category_name'] ?? null,
  279.                'category_main_category' => $subCategory['category_main_category'] ?? null,
  280.                'category_category' => $subCategory['category_category'] ?? null,
  281.                'category_main' => $subCategory['category_main'] ?? null,
  282.                'cnt' => $subCategory['cnt'] ?? null,
  283.                'image' => $this->CategoryService->getCategoryImageUrl($subCategory['category_id']),
  284.                'goods_image' => $this->CategoryService->getGoodsImageUrlByCatetoryId($subCategory['category_id']),
  285.            ];
  286.         }, $subCategoryList ?? []));
  287.         // TODO: ③【LM】共用コンテンツ(SP)のデータ取得
  288.         $common_header_contents_all '<div>
  289.         <a style="display: block; width: 100%;" href="/cart/add_catalog">
  290.         <picture><source media="(max-width: 320px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_320/smartphone/smp-catalog-2020aw-486x60.webp"><source media="(max-width: 640px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_640/smartphone/smp-catalog-2020aw-486x60.webp"><source type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images/smartphone/smp-catalog-2020aw-486x60.webp"><source media="(max-width: 320px)" srcset="https://img0.land-mark.biz/ut_img/public_images_320/smartphone/smp-catalog-2020aw-486x60.jpg"><source media="(max-width: 640px)" srcset="https://img0.land-mark.biz/ut_img/public_images_640/smartphone/smp-catalog-2020aw-486x60.jpg"><img style="width: 100%;" src="https://img0.land-mark.biz/ut_img/public_images/smartphone/smp-catalog-2020aw-486x60.jpg"></picture></a>
  291.         </div>
  292.         <div>
  293.         <a style="display: block; width: 100%;" href="/amazonpay/">
  294.         <picture><source media="(max-width: 320px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_320/categorypage/amazonpay/smp-486x60.webp"><source media="(max-width: 640px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_640/categorypage/amazonpay/smp-486x60.webp"><source type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images/categorypage/amazonpay/smp-486x60.webp"><source media="(max-width: 320px)" srcset="https://img0.land-mark.biz/ut_img/public_images_320/categorypage/amazonpay/smp-486x60.jpg"><source media="(max-width: 640px)" srcset="https://img0.land-mark.biz/ut_img/public_images_640/categorypage/amazonpay/smp-486x60.jpg"><img style="width: 100%;" src="https://img0.land-mark.biz/ut_img/public_images/categorypage/amazonpay/smp-486x60.jpg"></picture></a>
  295.         </div>
  296.         <script src="https://ajax.googlevapis.com/ajax/libs/jquery/2.2.4/jquery.2.4.1.min.js"></script>';
  297.         $main_category_name $data['main_category_name'];
  298.         $back_to_top_link = !empty($categoryData['main_bottomlink']) ? $categoryData['main_bottomlink'] : $categoryData['main_category_name'];
  299.         $category_bottom_text $categoryData['main_pagebottom'] ?? null;
  300.         $mainCategoryGroup $this->CategoryService->getMainCategoryGroupById($mc);
  301.         $mainCategoryData $this->CategoryService->getMainCategory($mcId);
  302.         $isShowCategoryData false;
  303.         if (
  304.             !empty($mainCategoryData['category_group_noshowdb']) && !$mainCategoryData['category_group_noshowdb'] &&
  305.             (
  306.                 (!empty($mainCategoryData['main_category_group']) && !in_array($mainCategoryData['main_category_group'], self::MAIN_CATEGORY_GROUPS_UNABLE_SHOW)) ||
  307.                 $detailData['item_count'] > 0
  308.             )
  309.         ) {
  310.             $isShowCategoryData true;
  311.         }
  312.         if(!empty($mainCategoryGroup['category_group_only_main']) && $mainCategoryGroup['category_group_only_main']){
  313.             $isMainOnly true;
  314.         }
  315.         $vendingStatusMap $this->GoodsService->getGoodsVendingStatusMap();
  316.         return [
  317.             'data' => $data,
  318.             'review' => $review,
  319.             'BreadCrumbs' => $BreadCrumbs,
  320.             'pager_pages_current_num' => $detailData['pager_pages_current_num'],
  321.             'upperColumnData' => $upperColumnData,
  322.             'columnList' => $columnList,
  323.             'canonicalMcData' => $canonicalMcData,
  324.             'categoryData' => $categoryData,
  325.             'dataItem' => $dataItem,
  326.             'subCategoryList' => $subCategoryList,
  327.             'ctName' => $ctName,
  328.             'mcName' => $mcName,
  329.             'mcMcName' => $mcMcName,
  330.             'content2' => $content2,
  331.             'content3' => $content3,
  332.             'isItemSeriesCategory' => $isItemSeriesCategory,
  333.             'isNoDisplayDbCategory' => $isNoDisplayDbCategory,
  334.             'detailItemCount' => $detailItemCount,
  335.             'categoryGroupNoshowdb' => $categoryGroupNoshowdb,
  336.             'detailData' => $detailData,
  337.             'main_h3' => $main_h3,
  338.             'main_breadcrumb' => $main_breadcrumb,
  339.             'seoKeywordTDK' => $seoKeywordTDK,
  340.             'category_h3' => $category_h3,
  341.             'category_h1' => $category_h1,
  342.             'useRecommendedItemOrder' => $useRecommendedItemOrder,
  343.             'breakCountForRankLabel' => $breakCountForRankLabel,
  344.             'useItemUrlDuplicated' => $useItemUrlDuplicated,
  345.             'mainCategoryData' => $mainCategoryData,
  346.             'common_header_contents_all' => $common_header_contents_all,
  347.             'common_header_contents' => $common_header_contents,
  348.             'recentviews' => $recentviews,
  349.             'custom_menu' => $custom_menu,
  350.             'custom_frequently_searched_word' => $custom_frequently_searched_word,
  351.             'isMainCategory' => $isMainCategory,
  352.             'is_no_display_db_category' => $is_no_display_db_category,
  353.             'showItemDb' => $showItemDb,
  354.             'useCache' => $useCache,
  355.             'pager_data' => $pager_data,
  356.             'max_display_cnt' => $max_display_cnt,
  357.             'canonical_category_name' => $canonical_category_name,
  358.             'average' => $average,
  359.             'isMainOnly' => $isMainOnly,
  360.             'isShowCategoryData' => $isShowCategoryData,
  361.             'items' => $items,
  362.             'canonicalSubCategoryList' => $canonicalSubCategoryList,
  363.             'leftmenuForCategoryData' => $leftmenuForCategoryData,
  364.             'canonicalMcName' => $canonicalMcName,
  365.             'ctId' => $ctId,
  366.             'main_category_name' => $main_category_name,
  367.             'MetaTags' => ['Category'=> $data ], # 2022/08/03 #kawai
  368.             'SubCate' => 0,
  369.             'back_to_top_link' => $back_to_top_link,
  370.             'category_bottom_text' => $category_bottom_text,
  371.             'vendingStatusMap' => $vendingStatusMap,
  372.         ];
  373.     }
  374.     /**
  375.      * @param Request $request
  376.      * @param string $ct
  377.      * @param string $mc
  378.      * @param string|null $mcMc
  379.      * #Route("/page/{mc}/{ct}", requirements={"mc" = "\w+", "ct" = "\w+"}, name="page/sub-category", methods={"GET"})
  380.      * @Template("Page/sub-category.twig")
  381.      * @return array|\Symfony\Component\HttpFoundation\Response
  382.      */
  383.     protected function _subCategory(Request $request$ct$mc$mcMc null)
  384.     {
  385.         //
  386.         $request->attributes->set('_route''page/sub-category');
  387.         $request->attributes->set('ct'$ct);
  388.         $request->attributes->set('mc'$mc);
  389.         $request->attributes->set('mcMc'$mcMc);
  390.         //
  391.         return $this->newCategory($request$mc$ct$mcMc, function ($category) use ($request$ct$mc$mcMc) {
  392.             //
  393.             return $this->__subCategory($request$category$ct$mc$mcMc);
  394.         });
  395.     }
  396.     protected function __subCategory(Request $requestCategoryWithRelated $category$ct$mc$mcMc null)
  397.     {
  398.         $data $this->dynamicConverter->getMainCategoryName($mc);
  399.         $data['mcId'] = $data['main_category_id'];
  400.         $data['mcName'] = $mc;
  401.         if ($ct != 'allitem') {
  402.             $subCategoryData $this->dynamicConverter->getSubCategoryName($data['main_category_id'], $ct);
  403.             $data['ctId'] = $subCategoryData['category_id'];
  404.             $data['ctName'] = $ct;
  405.         } else {
  406.             $data['ctId'] = 'allitem';
  407.             $data['ctName'] = 'allitem';
  408.         }
  409.         // モバイルの判定
  410.         $isMobile $this->MobileDetector->isMobile();
  411.         # Author Description Keyword Robots MetaTags
  412.         $Metatage = ['Author' => 'ああああ''Description' => 'いいい'];
  413.         $review = isset($data['main_category_id']) ? $this->dynamicConverter->getReview(nullfalse$data['main_category_id'], $data['ctId']) : [];
  414.         $columnList = [
  415.             [
  416.                 'uri' => '/',
  417.                 'column_custom_url' => '/custom_url',
  418.                 'main_category_webname' => 'work',
  419.                 'column_webname' => 'sagyogi-fashionable',
  420.                 'column_related_image_filename' => 'kanren.jpg  ',
  421.                 'column_related_image_alt' => 'ユニフォーム通販TOP',
  422.                 'column_name' => 'ユニフォーム通販TOP',
  423.                 'column_related_link_text' => 'ユニフォーム通販TOP',
  424.                 'column_h1_tag' => 'ユニフォーム通販TOP'
  425.             ],
  426.             [
  427.                 'uri' => '/',
  428.                 'column_custom_url' => '/custom_url',
  429.                 'main_category_webname' => 'work',
  430.                 'column_webname' => 'sagyogi-fashionable',
  431.                 'column_related_image_filename' => 'kanren.jpg  ',
  432.                 'column_related_image_alt' => 'ユニフォーム通販TOP',
  433.                 'column_name' => 'ユニフォーム通販TOP',
  434.                 'column_related_link_text' => 'ユニフォーム通販TOP',
  435.                 'column_h1_tag' => 'ユニフォーム通販TOP'
  436.             ]
  437.         ];
  438.         $upperColumnData $this->dynamicConverter->getByCategoryWebName(1$mc);
  439.         // TODO: canonicalMcDataを取得
  440.         $canonicalMcData null;
  441.         $categoryData $this->dynamicConverter->getCategoryData($data['main_category_id'], $data['category_id']);
  442.         $categoryData['main_category'] = $this->dynamicConverter->getMainCategoryData($data['main_category_id']);
  443.         $subCategoryList $this->dynamicConverter->getSubCategoryList($data['main_category_id']);
  444.         $canonicalSubCategoryList $this->dynamicConverter->getSubCategoryList($data['mcId']);
  445.         $BreadCrumbs = [
  446. //                        [
  447. //                            'label' => $categoryData['main_category_main_category_name'],
  448. //                            'href' => "/{$categoryData['main_category_main_category_webname']}",
  449. //                        ],
  450.                         [
  451.                             'label' => $categoryData['main_category_name'],
  452.                             'href' => "{$categoryData['main_category_main_category_webname']}/{$categoryData['main_category_webname']}",
  453.                         ],
  454.                         [
  455.                             'label' => $categoryData['category_name'],
  456.                             'href' => "{$categoryData['main_category_main_category_webname']}/{$categoryData['main_category_webname']}/{$categoryData['category_webname']}",
  457.                         ],
  458.                     ];
  459.         $mcMcName $mc;
  460.         $mcName $mc;
  461.         $ctName $data['ctName'];
  462.         $ctId $data['ctId'];
  463.         $mcId $data['main_category_id'];
  464.         $orderType $this->session->has('order_type') ? $this->session->get('order_type') : $request->get('type');
  465.         $display_item_count_list $this->CommonService->GetYaml('DisplayItem.yaml');
  466.         $displayMax $this->session->has('display_max') ? intval($this->session->get('display_max')) : intval($request->get('disp'));
  467.         if ($displayMax == $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW']) {
  468.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW'];
  469.         } else if ($displayMax == $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH']) {
  470.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH'];
  471.         } else if ($displayMax == $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT']) {
  472.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT'];
  473.         } else {
  474.             $max_display_cnt $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT'];
  475.         }
  476.         $dataItem "";
  477.         $dataItem $this->_getDataItem($request$mcId$ctId$mcName$ctName$max_display_cnt$item_count);
  478.         $detailData = array();
  479.         $detailData['item_count'] = $item_count;
  480. //        $detailData['item_count'] = count($dataItem);
  481.         $detailData['item'] = $dataItem;
  482.         $detailData['pager_pages_current_num'] = 0;
  483.         $detailData['col_count'] = $isMobile 3;
  484.         $detailData['max_display_cnt'] = $max_display_cnt;
  485.         if (!empty($request->get('no')) && intval($request->get('no')) > 0) {
  486.             $detailData['min_cnt'] = min((intval($request->get('no')) + 1), $detailData['item_count']);
  487.         } else {
  488.             $detailData['min_cnt'] = min(1$detailData['item_count']);
  489.         }
  490.         $detailData['max_cnt'] = min($detailData['min_cnt'] + $detailData['max_display_cnt'] - 1$detailData['item_count']);
  491.         for ($i 1$i <= $detailData['item_count']; $i += $detailData['max_display_cnt']) {
  492.             if ($detailData['min_cnt'] >= $i and $detailData['max_cnt'] <= ($i $detailData['max_display_cnt'])) {
  493.                 $detailData['pager_pages_current_num'] = intval($i $detailData['max_display_cnt']) + 1;
  494.             }
  495.         }
  496.         $an_sort = array();
  497.         for ($i 0$i $detailData['item_count']; $i++) {
  498.             $an_sort["$i"] = $i;
  499.         }
  500.         $i 0;
  501.         foreach ($an_sort as $k => $v) {
  502.             // $an_v[$i] = $k;
  503.             $an_v[$i] = $i;
  504.             $i++;
  505.         }
  506.         $detailData['an_v'] = $an_sort;
  507.         $main_category_url2_content $isMobile && $categoryData['main_category']['main_category_url2_sp_content'] != '' $categoryData['main_category']['main_category_url2_sp_content'] : ($categoryData['main_category']['main_category_url2_content'] ?? '');
  508.         $main_category_url2_content2 $isMobile && $categoryData['main_category']['main_category_url2_sp_content2'] != '' $categoryData['main_category']['main_category_url2_sp_content2'] : ($categoryData['main_category']['main_category_url2_content2'] ?? '');
  509.         $main_category_url2_content3 $isMobile && $categoryData['main_category']['main_category_url2_sp_content3'] != '' $categoryData['main_category']['main_category_url2_sp_content3'] : ($categoryData['main_category']['main_category_url2_content3'] ?? '');
  510.         $main_category_url2_content4 $isMobile && $categoryData['main_category']['main_category_url2_sp_content4'] != '' $categoryData['main_category']['main_category_url2_sp_content4'] : ($categoryData['main_category']['main_category_url2_content4'] ?? '');
  511.         $main_category_url2_content5 $isMobile && $categoryData['main_category']['main_category_url2_sp_content5'] != '' $categoryData['main_category']['main_category_url2_sp_content5'] : ($categoryData['main_category']['main_category_url2_content5'] ?? '');
  512.         $main_category_url2_content6 $isMobile && $categoryData['main_category']['main_category_url2_sp_content6'] != '' $categoryData['main_category']['main_category_url2_sp_content6'] : ($categoryData['main_category']['main_category_url2_content6'] ?? '');
  513.         $main_category_url2_content7 $isMobile && $categoryData['main_category']['main_category_url2_sp_content7'] != '' $categoryData['main_category']['main_category_url2_sp_content7'] : ($categoryData['main_category']['main_category_url2_content7'] ?? '');
  514.         $main_category_url2_content8 $isMobile && $categoryData['main_category']['main_category_url2_sp_content8'] != '' $categoryData['main_category']['main_category_url2_sp_content8'] : ($categoryData['main_category']['main_category_url2_content8'] ?? '');
  515.         $main_category_url2_content9 $isMobile && $categoryData['main_category']['main_category_url2_sp_content9'] != '' $categoryData['main_category']['main_category_url2_sp_content9'] : ($categoryData['main_category']['main_category_url2_content9'] ?? '');
  516.         $main_category_url2_content10 $isMobile && $categoryData['main_category']['main_category_url2_sp_content10'] != '' $categoryData['main_category']['main_category_url2_sp_content10'] : ($categoryData['main_category']['main_category_url2_content10'] ?? '');
  517.         $main_category_url2_content11 $isMobile && $categoryData['main_category']['main_category_url2_sp_content11'] != '' $categoryData['main_category']['main_category_url2_sp_content11'] : ($categoryData['main_category']['main_category_url2_content11'] ?? '');
  518.         $main_category_url2_content12 $isMobile && $categoryData['main_category']['main_category_url2_sp_content12'] != '' $categoryData['main_category']['main_category_url2_sp_content12'] : ($categoryData['main_category']['main_category_url2_content12'] ?? '');
  519.         // TODO: content2を取得
  520.         $content2 '';
  521.         // TODO: content3を取得
  522.         $content3 '';
  523.         //TODO: 「関連するページ」リンクの表示
  524.         $isItemSeriesCategory 1;
  525.         $isNoDisplayDbCategory 0;
  526.         $detailItemCount 1;
  527.         $categoryGroupNoshowdb 0;
  528.         $breakCountForRankLabel 1;
  529.         $useItemUrlDuplicated false;
  530.         $mainCategoryData = array();
  531.         $main_h3 $categoryData['main_category']['main_h3_tag'];
  532.         $main_breadcrumb $categoryData['main_category']['main_breadcrumb'];
  533.         // TODO: category_h3を取得
  534.         $category_h3 '';
  535.         // TODO: category_h1を取得
  536.         $category_h1 '';
  537.         $seoKeywordTDK '';
  538.         if ($categoryData['category_name'] == "全商品") {
  539.             $seoKeyword $seoKeywordTDK $categoryData['main_category_name'] . " " $categoryData['category_name'];
  540.         } elseif (in_array($data['main_category_name'], array("メディカルウェア""エステユニフォーム"))) { // パターンA
  541.             $seoKeyword $categoryData['category_name'];
  542.             $seoKeywordTDK $categoryData['category_name'] . "(" $data['main_category_name'] . ")";
  543.         } elseif (in_array($data['main_category_name'], array("作業服・作業着""作業服バートル""医療白衣""エプロン""防寒服""スタッフジャンパー""シャツ""ポロシャツ"))) { // パターンB
  544.             $seoKeyword $seoKeywordTDK $categoryData['category_name'];
  545.         } else { // パターンC
  546.             $seoKeyword $seoKeywordTDK $data['main_category_name'] . " " $categoryData['category_name'];
  547.         }
  548.         $useRecommendedItemOrder $this->dynamicConverter->useUnItemOrder($data['mcId'], $data['ctId']);
  549.         if ($mcMc) {
  550.             $custom_menu $this->dynamicConverter->getMainCategoryMenu($mcMc);
  551.         } else {
  552.             $custom_menu $this->dynamicConverter->getMainCategoryMenu($mc);
  553.         }
  554.         $custom_frequently_searched_word $this->dynamicConverter->getSearchWordGroup($this->eccubeConfig['EditSpMenu']['MENU_NAME_COMMON'], $this->eccubeConfig['EditSpMenu']['BOOL_TRUE']);
  555.         $recentviews = [];
  556.         $common_header_contents null;
  557.         $isMainCategory false;
  558.         // TODO: ⑧【LM】商品一覧
  559.         $category = new CategoryWithRelated($mc$ct$mcMc$isMobile);
  560.         $is_no_display_db_category $category->isNoDisplayDbCategory();
  561.         $showItemDb false;
  562.         $useCache false;
  563.         $max_display_cnt 10;
  564.         $canonical_category_name '';
  565.         $average = array();
  566.         if ( !$data['category_group_noshowdb'] &&
  567.             // array(7, 8) 7:説明別, 8: メーカー別
  568.             ( !in_array($data['main_category_group'], array(78)) || $detailData['item_count'] > 0) ) {
  569.                 $showItemDb true;
  570.         }
  571.         $pager_data $this->CategoryService->getPagerData(
  572.             $category->getCanonicalMainCategoryWebname(),
  573.             $ct,
  574.             $detailData['max_display_cnt'],
  575.             $detailData['item_count'],
  576.             $detailData['min_cnt'],
  577.             $detailData['max_cnt'],
  578.             $displayMax,
  579.             $orderType,
  580.             $isMobile
  581.         );
  582.         // TODO: ⑨【LM】カテゴリ絞り込み(SP)
  583.         $isMainOnly false;
  584.         $leftmenuForCategoryData = [];
  585.         $canonicalMcName $mcName;
  586.         $items array_values(array_map(function($subCategory) {
  587.             return [
  588.                 'category_id' => $subCategory['category_id'] ?? null,
  589.                 'category_name' => $subCategory['category_name'] ?? null,
  590.                 'category_main_category' => $subCategory['category_main_category'] ?? null,
  591.                 'category_category' => $subCategory['category_category'] ?? null,
  592.                 'category_main' => $subCategory['category_main'] ?? null,
  593.                 'cnt' => $subCategory['cnt'] ?? null,
  594.                 'image' => $this->CategoryService->getCategoryImageUrl($subCategory['category_id']),
  595.                 'goods_image' => $this->CategoryService->getGoodsImageUrlByCatetoryId($subCategory['category_id']),
  596.             ];
  597.         }, $subCategoryList ?? []));
  598.         // TODO: ③【LM】共用コンテンツ(SP)のデータ取得
  599.         $common_header_contents_all '<div>
  600.         <a style="display: block; width: 100%;" href="/cart/add_catalog">
  601.         <picture><source media="(max-width: 320px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_320/smartphone/smp-catalog-2020aw-486x60.webp"><source media="(max-width: 640px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_640/smartphone/smp-catalog-2020aw-486x60.webp"><source type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images/smartphone/smp-catalog-2020aw-486x60.webp"><source media="(max-width: 320px)" srcset="https://img0.land-mark.biz/ut_img/public_images_320/smartphone/smp-catalog-2020aw-486x60.jpg"><source media="(max-width: 640px)" srcset="https://img0.land-mark.biz/ut_img/public_images_640/smartphone/smp-catalog-2020aw-486x60.jpg"><img style="width: 100%;" src="https://img0.land-mark.biz/ut_img/public_images/smartphone/smp-catalog-2020aw-486x60.jpg"></picture></a>
  602.         </div>
  603.         <div>
  604.         <a style="display: block; width: 100%;" href="/amazonpay/">
  605.         <picture><source media="(max-width: 320px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_320/categorypage/amazonpay/smp-486x60.webp"><source media="(max-width: 640px)" type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images_640/categorypage/amazonpay/smp-486x60.webp"><source type="image/webp" srcset="https://img0.land-mark.biz/ut_img/public_images/categorypage/amazonpay/smp-486x60.webp"><source media="(max-width: 320px)" srcset="https://img0.land-mark.biz/ut_img/public_images_320/categorypage/amazonpay/smp-486x60.jpg"><source media="(max-width: 640px)" srcset="https://img0.land-mark.biz/ut_img/public_images_640/categorypage/amazonpay/smp-486x60.jpg"><img style="width: 100%;" src="https://img0.land-mark.biz/ut_img/public_images/categorypage/amazonpay/smp-486x60.jpg"></picture></a>
  606.         </div>
  607.         <script src="https://ajax.googlevapis.com/ajax/libs/jquery/2.2.4/jquery.2.4.1.min.js"></script>';
  608.         $main_category_name $data['category_name'];
  609.         $back_to_top_link = !empty($subCategoryList[$ctId]['category_bottomlink']) ? $subCategoryList[$ctId]['category_bottomlink'] : $subCategoryList[$ctId]['category_name'];
  610.         $category_bottom_text $subCategoryList[$ctId]['category_pagebottom'] ?? null;
  611.         // TODO: ⑨【LM】カテゴリ(子)_H1タグ
  612.         $addToHeadTitle '';
  613.         $mainCategoryGroup $this->CategoryService->getMainCategoryGroupById($mc);
  614.         $mainCategoryData $this->CategoryService->getMainCategory($mcId);
  615.         $isShowCategoryData false;
  616.         if (
  617.             !empty($mainCategoryData['category_group_noshowdb']) && !$mainCategoryData['category_group_noshowdb'] &&
  618.             (
  619.                 (!empty($mainCategoryData['main_category_group']) && !in_array($mainCategoryData['main_category_group'], self::MAIN_CATEGORY_GROUPS_UNABLE_SHOW)) ||
  620.                 $detailData['item_count'] > 0
  621.             )
  622.         ) {
  623.             $isShowCategoryData true;
  624.         }
  625.         if(!empty($mainCategoryGroup['category_group_only_main']) && $mainCategoryGroup['category_group_only_main']){
  626.             $isMainOnly true;
  627.         }
  628.         $vendingStatusMap $this->GoodsService->getGoodsVendingStatusMap();
  629.         return [
  630.             'data' => $data,
  631.             'review' => $review,
  632.             'pager_pages_current_num' => $detailData['pager_pages_current_num'],
  633.             'upperColumnData' => $upperColumnData,
  634.             'columnList' => $columnList,
  635.             'canonicalMcData' => $canonicalMcData,
  636.             'categoryData' => $categoryData,
  637.             'dataItem' => $dataItem,
  638.             'subCategoryList' => $subCategoryList,
  639.             'ctName' => $ctName,
  640.             'mcName' => $mcName,
  641.             'mcMcName' => $mcMcName,
  642.             'main_category_url2_content' => $main_category_url2_content,
  643.             'main_category_url2_content2' => $main_category_url2_content2,
  644.             'main_category_url2_content3' => $main_category_url2_content3,
  645.             'main_category_url2_content4' => $main_category_url2_content4,
  646.             'main_category_url2_content5' => $main_category_url2_content5,
  647.             'main_category_url2_content6' => $main_category_url2_content6,
  648.             'main_category_url2_content7' => $main_category_url2_content7,
  649.             'main_category_url2_content8' => $main_category_url2_content8,
  650.             'main_category_url2_content9' => $main_category_url2_content9,
  651.             'main_category_url2_content10' => $main_category_url2_content10,
  652.             'main_category_url2_content11' => $main_category_url2_content11,
  653.             'main_category_url2_content12' => $main_category_url2_content12,
  654.             'content2' => $content2,
  655.             'content3' => $content3,
  656.             'isItemSeriesCategory' => $isItemSeriesCategory,
  657.             'isNoDisplayDbCategory' => $isNoDisplayDbCategory,
  658.             'detailItemCount' => $detailItemCount,
  659.             'categoryGroupNoshowdb' => $categoryGroupNoshowdb,
  660.             'detailData' => $detailData,
  661.             'main_h3' => $main_h3,
  662.             'main_breadcrumb' => $main_breadcrumb,
  663.             'category_h3' => $category_h3,
  664.             'category_h1' => $category_h1,
  665.             'useRecommendedItemOrder' => $useRecommendedItemOrder,
  666.             'breakCountForRankLabel' => $breakCountForRankLabel,
  667.             'useItemUrlDuplicated' => $useItemUrlDuplicated,
  668.             'mainCategoryData' => $mainCategoryData,
  669.             'common_header_contents_all' => $common_header_contents_all,
  670.             'common_header_contents' => $common_header_contents,
  671.             'recentviews' => $recentviews,
  672.             'custom_menu' => $custom_menu,
  673.             'custom_frequently_searched_word' => $custom_frequently_searched_word,
  674.             'isMainCategory' => $isMainCategory,
  675.             'is_no_display_db_category' => $is_no_display_db_category,
  676.             'showItemDb' => $showItemDb,
  677.             'useCache' => $useCache,
  678.             'pager_data' => $pager_data,
  679.             'max_display_cnt' => $max_display_cnt,
  680.             'canonical_category_name' => $canonical_category_name,
  681.             'average' => $average,
  682.             'isMainOnly' => $isMainOnly,
  683.             'isShowCategoryData' => $isShowCategoryData,
  684.             'items' => $items,
  685.             'canonicalSubCategoryList' => $canonicalSubCategoryList,
  686.             'leftmenuForCategoryData' => $leftmenuForCategoryData,
  687.             'canonicalMcName' => $canonicalMcName,
  688.             'ctId' => $ctId,
  689.             'main_category_name' => $main_category_name,
  690.             'BreadCrumbs' => $BreadCrumbs,
  691.             'seoKeywordTDK' => $seoKeywordTDK,
  692.             'addToHeadTitle' => $addToHeadTitle,
  693.             'MetaTags' => ['SubCategory'=> $data ], # 2022/08/03 #kawai
  694.             'SubCate' => 1,
  695.             'back_to_top_link' => $back_to_top_link,
  696.             'category_bottom_text' => $category_bottom_text,
  697.             'vendingStatusMap' => $vendingStatusMap,
  698.         ];
  699.     }
  700.     /**
  701.      * @param Request $request
  702.      * @param CategoryWithRelated $category
  703.      * @param string $mc
  704.      * @param string $ct
  705.      * @param string $mcMc
  706.      * @param array|callable $parameters
  707.      * @return mixed|null
  708.      * @throws \ErrorException
  709.      * @throws \Psr\Cache\InvalidArgumentException
  710.      */
  711.     public function newCategory(Request $request$mc$ct null$mcMc null$parameters = [])
  712.     {
  713.         //
  714.         $isMobile $this->MobileDetector->isMobile();
  715.         //
  716.         $device $isMobile 'sp' 'pc';
  717.         //
  718.         $layoutId $isMobile null 24;  // TODO: マジックナンバー: 24
  719.         // レイアウトの指定
  720.         $this->CommonService->SetPageLayout('page/sub-category'$isMobile, [], $layoutId);
  721.         //
  722.         $masterCacheKey self::getMasterCacheKey($mc$ct);
  723.         // 絞込み対応(SESSION内の検索条件をキャッシュIDのサフィックス生成要素に加える)
  724.         $suffix = (function(array $_get, array $_session) {
  725.             //
  726.             $_params array_merge(array_intersect_key($_getarray_flip([
  727.                 'no',
  728.                 'disp',
  729.                 'type',
  730.             ])), array_intersect_key($_sessionarray_flip([
  731.                 'display_max',
  732.                 'order_type',
  733.                 'price_range_end',
  734.                 'price_range_start',
  735.                 'search_base_color_list',
  736.                 'search_size_list',
  737.                 'search_type_list',
  738.             ])));
  739.             //
  740.             return !empty($_params) ? hash('sha256'base64_encode(serialize($_params))) : '';
  741.         })($request->query->all(), $this->session->all());
  742.         //
  743.         $viewCacheKey "{$masterCacheKey}__{$device}_view__{$suffix}";
  744.         //
  745.         $masterCache $this->handleMasterCache($masterCacheKey$device, [
  746.             $viewCacheKey,
  747.         ]);
  748.         return $this->getCacheByKey($viewCacheKey, function () use ($request$isMobile$mc$ct$mcMc$parameters) {
  749.             /**
  750.              * ページング関連のセッションを設定(表示順など)
  751.              */
  752.             $this->setCategoryPagingSession($request);
  753.             // レイアウトの指定
  754.             try {
  755.                 // 親・子・祖父
  756.                 $category = new CategoryWithRelated($mc$ct$mcMc$isMobile);
  757.             } catch (\Exception $e) {
  758.                 // カテゴリデータの取得に失敗した場合「404 Not Found」とする
  759.                 throw new NotFoundHttpException("指定されたカテゴリのデータが取得出来ませんでした({$e->getMessage()})"$e);
  760.             }
  761.             return $this->_newCategory($category$isMobile$mc$ct$mcMc$parameters);
  762.         });
  763.     }
  764.     /**
  765.      * @param bool $isMobile
  766.      * @param string $mc
  767.      * @param string $ct
  768.      * @param string $mcMc
  769.      * @param array|callable $parameters
  770.      * @return array
  771.      */
  772.     public function _newCategory(CategoryWithRelated $category$isMobile$mc$ct null$mcMc null$parameters = [])
  773.     {
  774.         //
  775.         if (is_callable($parameters)) {
  776.             //
  777.             $parameters $parameters($category);
  778.         }
  779.         //
  780.         $BreadCrumbs $category->getBreadCrumbs();
  781.         // TODO: ビューからの呼出しのみに統合
  782.         $contents_block_map $category->getContentsBlockMap();
  783.         $metaTags = [
  784.             $category->getMetaTags(),
  785.         ];
  786.         //
  787.         $main_h1 null;
  788.         $category_h1 null;
  789.         $h1_comment $category->getH1Content();
  790.         //
  791.         $this->dataLayer['gdn']['items'] = array_map(function ($id) {
  792.             return $this->CommonService->get_google_retargeting_item($id);
  793.         }, array_column(array_slice($parameters['detailData']['item'], 03), 'goods_id'));
  794.         $this->dataLayer['ydn']['yahoo_retargeting_items'] = array_map(function ($id) {
  795.             return $this->CommonService->get_yahoo_retargeting_item($id);
  796.         }, array_column(array_slice($parameters['detailData']['item'], 03), 'goods_id'));
  797.         $this->dataLayer['criteo']['item'] = array_column(array_slice($parameters['detailData']['item'], 03), 'goods_id');
  798.         //
  799.         $parameters array_merge($parameters, [
  800.             'mcMcName' => $mcMc,
  801.             'mcName' => $mc,
  802.             'BreadCrumbs' => $BreadCrumbs,
  803.             'breadCrumb' => $BreadCrumbs,
  804.             'category' => $category,
  805.             'contents_block_map' => $contents_block_map,    // TODO: ビューからの呼出しのみに統合
  806.             'MetaTags' => $metaTags,                        // TODO: ビューからの呼出しのみに統合
  807.             'sashikomiTitleHtml' => $category->getTitleContent(),
  808.             'dataLayer' => $this->dataLayer,
  809.             'main_h1' => $main_h1,
  810.             'category_h1' => $category_h1,
  811.             'h1_comment' => $h1_comment,
  812.             'ct' => $ct,
  813.             'isMobile' => $isMobile
  814.         ]);
  815.         //
  816.         // return $this->render('Page/sub-category.twig', $parameters);
  817.         return $parameters;
  818.     }
  819.     /**
  820.      * @param Request $request
  821.      * @param null $cd
  822.      * @Template("Page/sub-category.twig")
  823.      */
  824.     public function mainCategory(Request $request)
  825.     {
  826.         //
  827.         $Uri $request->server->get('REQUEST_URI');
  828.         list($mc) = explode('/'trim(str_replace($request->getBasePath(), ''$Uri), '/'));
  829.         //
  830.         return $this->_mainCategory($request$mc);
  831.     }
  832.     /**
  833.      * @param Request $request
  834.      * @param null $cd
  835.      * @Template("Page/sub-category.twig")
  836.      */
  837.     public function mainCategoryMainCategory(Request $request$mc null$mcMc null)
  838.     {
  839.         //
  840.         $uri $request->getRequestUri();
  841.         $paths explode('/'trim($uri'/'));
  842.         //
  843.         if ($paths[0] !== $mcMc) {
  844.             // //
  845.             // error_log('[PageController::mainCategoryMainCategory] '.json_encode(compact('uri', 'paths', 'mc', 'mcMc')));
  846.             //
  847.             $queries $request->query->all();
  848.             $parameters array_merge($queries, [
  849.             ]);
  850.             //
  851.             $route "ct1_{$mcMc}__ct2_{$mc}";
  852.             $route str_replace('-''_'$route);
  853.             //
  854.             return $this->redirectToRoute($route$parameters301);
  855.         }
  856.         //
  857.         return $this->_mainCategory($request$mc$mcMc);
  858.     }
  859.     /**
  860.      * @param Request $request
  861.      * @param null $cd
  862.      * @Template("Page/sub-category.twig")
  863.      */
  864.     public function subCategory(Request $request$ct3 null)
  865.     {
  866.         //
  867.         $Uri $request->server->get('REQUEST_URI');
  868.         list($mc) = explode('/'trim(str_replace($request->getBasePath(), ''$Uri), '/'));
  869.         $ct $ct3;
  870.         //
  871.         return $this->_subCategory($request$ct$mc);
  872.     }
  873.     /**
  874.      * @param Request $request
  875.      * @param null $cd
  876.      * @Template("Page/sub-category.twig")
  877.      */
  878.     public function mainCategorySubCategory(Request $request$ct1 null$ct2 null$ct3 null)
  879.     {
  880.         //
  881.         $uri $request->getRequestUri();
  882.         $paths explode('/'trim($uri'/'));
  883.         //
  884.         if ($paths[0] !== $ct1) {
  885.             // //
  886.             // error_log('[PageController::mainCategoryMainCategory] '.json_encode(compact('uri', 'paths', 'mc', 'mcMc')));
  887.             //
  888.             $queries $request->query->all();
  889.             $parameters array_merge($queries, [
  890.                 'ct3' => $ct3,
  891.             ]);
  892.             //
  893.             $route "ct1_{$ct1}__ct2_{$ct2}__ct3_";
  894.             $route str_replace('-''_'$route);
  895.             //
  896.             return $this->redirectToRoute($route$parameters301);
  897.         }
  898.         $mcMc $ct1;
  899.         $mc $ct2;
  900.         $ct $ct3;
  901.         //
  902.         return $this->_subCategory($request$ct$mc$mcMc);
  903.     }
  904.     private function _getDataItem($request$mcId$ctId$mcName$ctName$max_display_cnt, &$item_count null)
  905.     {
  906.         $an_search_base_color_list = array();
  907.         //$FRONT_PATH = $this->eccubeConfig['FRONT_PATH'];
  908.         $FRONT_PATH "";
  909.         if ($this->session->has('search_base_color_list') && $this->session->get('search_base_color_list') != '') {
  910.             $k 0;
  911.             $basename $FRONT_PATH "an_ct/" $mcName "/" $ctName;
  912.         }
  913.         // サイズで選ぶ
  914.         $an_search_size_list = array();
  915.         if ($this->session->has('search_size_list') && $this->session->get('search_size_list') != '') {
  916.             $k 0;
  917.             $basename $FRONT_PATH "an_ct/" $mcName "/" $ctName;
  918.         }
  919.         // 種類で選ぶ
  920.         $an_search_type_list = array();
  921.         if ($this->session->has('search_type_list') && $this->session->get('search_type_list') != '') {
  922.             $k 0;
  923.             $basename $FRONT_PATH "an_ct/" $mcName "/" $ctName;
  924.         }
  925.         $strSQLWhere '';
  926.         $search_goods_id array_unique($an_search_base_color_list $an_search_size_list $an_search_type_list);
  927.         if (is_array($search_goods_id) && $search_goods_id) {
  928.             $strSQLWhere .= ' AND goods_id in (' implode(','$search_goods_id) . ')';
  929.         }
  930.         $strSQLGroup " group by goods_id";
  931.         // 金額で選ぶ
  932.         $strSQLHaving '';
  933.         if (($this->session->has('price_range_start') && $this->session->get('price_range_start') != '') || ($this->session->has('price_range_end') && $this->session->get('price_range_end') != '')) {
  934.             $price_range_start $this->session->get('price_range_start');
  935.             $price_range_end $this->session->get('price_range_end');
  936.             $strSQLHaving ' HAVING ';
  937.             // 「範囲」検索
  938.             if ($price_range_start != "" && $price_range_end != "") {
  939.                 $strSQLHaving .= ' price >= ' $price_range_start ' AND price <= ' $price_range_end;
  940.             } else if ($price_range_start != "") {
  941.                 $strSQLHaving .= ' price >= ' $price_range_start;
  942.             } else if ($price_range_end != "") {
  943.                 $strSQLHaving .= ' price <= ' $price_range_end;
  944.             }
  945.         }
  946.         if ($ctId != "allitem") {
  947.             $search_category $this->dynamicConverter->_getOriginalCategory($ctId);
  948.         } else {
  949.             $search_category $this->dynamicConverter->_getOriginalCategory_Main($mcId);
  950.         }
  951.         $mcConditions '';
  952.         $ctConditions '';
  953.         if (!empty($mcId)) {
  954.             $mcConditions " AND main_category_id = {$mcId}";
  955.         }
  956.         if (!empty($ctId) && $ctId !== 'allitem') {
  957.             $ctConditions " AND category_id IN ({$search_category})";
  958.         }
  959.         elseif (!empty($search_category)) {
  960.             $ctConditions " AND category_id IN ({$search_category})";
  961.         }
  962.         // ユニフォームネクストの商品掲載順を使用(おすすめとして扱う)
  963.         $use_recommended_order $this->dynamicConverter->useUnItemOrder($mcId$ctId);
  964.         $join_item_recommended_order '';
  965.         $orderType $this->session->has('order_type') ? $this->session->get('order_type') : $request->get('type');
  966.         if( $use_recommended_order && (int)$orderType === ){
  967.             $recommended_order_where_clause 'main_category_id = %d';
  968.             if( !empty($ctId) && strtolower($ctId) !== 'allitem' ){
  969.                 $recommended_order_where_clause .= ' AND category_id = %d';
  970.             }
  971.             else{
  972.                 $recommended_order_where_clause .= ' AND category_id IS NULL';
  973.             }
  974.             $join_item_recommended_order sprintf("
  975.                     LEFT JOIN(
  976.                         SELECT
  977.                             goods_id,
  978.                             is_un_order,
  979.                             display_order
  980.                         FROM
  981.                             goods_recommended_order_table
  982.                         WHERE
  983.                             {$recommended_order_where_clause}
  984.                     ) AS recommended_order
  985.                     USING(goods_id)
  986.                 ",
  987.                 $mcId,
  988.                 $ctId
  989.             );
  990.         }
  991.         /***** 商品情報取得(メイン) *****/
  992.         $strSQL "select SQL_CALC_FOUND_ROWS goods_id, goods_canonical_hinban, goods_recommend, goods_name, goods_sub_name, goods_caption, goods_display, goods_cdate, goods_udate, price2_min as price, kataban, NULL AS category_id, COALESCE(cra_average_points, 0) AS average, cra_target_count as review_count, goods_target_gender, goods_category_list_icon_id
  993.             from (
  994.                 select goods_id, goods_canonical_hinban, goods_recommend, goods_name, goods_sub_name, goods_caption, goods_display, goods_cdate, goods_udate, goods_target_gender, goods_category_list_icon_id,
  995.                 main_category_id, category_id
  996.                 from main_category_table
  997.                 inner join category_table on main_category_id = category_main_category
  998.                 inner join goods_category_table on category_id = gc_category
  999.                 inner join goods_table on goods_id = gc_goods
  1000.                 where 1 = 1{$mcConditions}{$ctConditions} AND goods_ddate is null and goods_status = 1
  1001.                 union
  1002.                 select goods_id, goods_canonical_hinban, goods_recommend, goods_name, goods_sub_name, goods_caption, goods_display, goods_cdate, goods_udate, goods_target_gender, goods_category_list_icon_id,
  1003.                 main_category_id, null as category_id
  1004.                 from main_category_table
  1005.                 inner join goods_main_category_table on main_category_id = gmc_main_category
  1006.                 inner join goods_table on goods_id = gmc_goods
  1007.                 where 1 = 1{$mcConditions} AND goods_ddate is null and goods_status = 1
  1008.             ) AS goods
  1009.             inner join goods_price_summary USING( goods_id )
  1010.             left join sales_volume_rank_table USING( goods_id )
  1011.             left join customer_review_average_table on cra_goods_id = goods_id
  1012.             {$join_item_recommended_order}
  1013.             WHERE 1 = 1{$mcConditions}";
  1014.         if( strtolower($ctId) !== 'allitem' $strSQL .= $ctConditions;
  1015.         $strSQL .= $strSQLWhere $strSQLGroup $strSQLHaving;
  1016.         if ($orderType == "1" ) {
  1017.             //安い順
  1018.             $strSQL .= " order by price, goods_recommend desc ";
  1019.         } elseif ($orderType == "3" ) {
  1020.             //高い順
  1021.             $strSQL .= " order by price desc, goods_recommend desc ";
  1022.         } elseif ($orderType == "4" ) {
  1023.             //品名順
  1024.             // $strSQL .= " order by cast( goods_name as binary ), goods_recommend desc ";
  1025.             $strSQL .= " order by goods_recommend desc ";
  1026.         } elseif ($orderType == "2" ) {
  1027.             //品番順
  1028.             $strSQL .= " order by kataban, goods_recommend desc ";
  1029.         } elseif ($orderType == "5" ) {
  1030.             // 評価順
  1031.             $strSQL .= " order by average desc, review_count desc,goods_recommend desc ";
  1032.         } elseif ($orderType == "6" and $use_recommended_order) {
  1033.             // おすすめ順(ユニフォームネクストの商品掲載順)
  1034.             // ユニフォームネクストと紐付きのない商品は、「ウェブスクレイピング画面で設定した順 > goods_id順’で表示
  1035.             $strSQL .= " order by is_un_order DESC, display_order IS NULL ASC, display_order ASC, goods_id";
  1036.         } else {
  1037.             $strSQL .= " order by isnull( quantities ), quantities DESC, goods_recommend desc, price, isnull( goods_display ), goods_display, goods_udate desc, goods_cdate desc ";
  1038.         }
  1039.         // Note. no に意図せずマイナス数値が与えられてしまった場合の保全対応として、limit に与える数値を判定する
  1040.         $start intval($request->get('no'));
  1041.         $start = ($start 0) ? $start;
  1042.         $strSQL .= ' limit ' $start ',' $max_display_cnt;
  1043.         $tempRow $this->dynamicConverter->getDataBySql($strSQL);
  1044.         if (empty($tempRow)) return [];
  1045.         $tmp_row 0;
  1046.         foreach ($tempRow as $row) {
  1047.             $tmp_row++;
  1048.             $ret['item'][$tmp_row-1] = $row;
  1049.         }
  1050.         /***** 商品数を取得 *****/
  1051.         $tempRow $this->dynamicConverter->getDataBySql("SELECT FOUND_ROWS()""{$mcId}_{$ctId}");
  1052.         $item_count $tempRow[0]['FOUND_ROWS()'];
  1053.         $ret['item_count'] = 0;
  1054.         $ret['style'] = "columnProduct3";
  1055.         $ret['search_area'] = "";
  1056.         $ret['col_count'] = 3;
  1057.         $ret['max_display_cnt'] = 30;
  1058.         $ret['item_count'] = $item_count;
  1059.         $data['item_count'] = $ret['item_count'];
  1060.         $data['style'] = $ret['style'];
  1061.         $data['search_area'] = $ret['search_area'];
  1062.         $data['col_count'] = $ret['col_count'];
  1063.         $data['item'] = $ret['item'];
  1064.         $an_search_base_color_list = array();
  1065.         $an_search_type_list = array();
  1066.         $an_search_size_list = array();
  1067.         for ($i 0$i count($data['item']); $i++) {
  1068.             $item_price_list[] = $data["item"][$i]["price"];
  1069.         }
  1070.         $data['max_price'] = max($item_price_list);
  1071.         $data['min_price'] = min($item_price_list);
  1072.         $data['style'] = "columnCoordinate0";
  1073.         $data['search_area'] = " style=\"display:none;\"";
  1074.         // $data['col_count'] = $sp == 1 ? 2 : 3;
  1075.         // 表示数チェック
  1076.         if (isset($_GET['no']) and intval($_GET['no']) > 0) {
  1077.             $data['min_cnt'] = min((intval($_GET['no']) + 1), $data['item_count']);
  1078.         } else {
  1079.             $data['min_cnt'] = min(1$data['item_count']);
  1080.         }
  1081.         $data['max_cnt'] = min($data['min_cnt'] + $max_display_cnt 1$data['item_count']);
  1082.         // クロスサイトスクリプティング対策
  1083.         if (isset($_GET['type']) and $_GET['type'] != "" and !preg_match("/^[0-9]+$/"$_GET['type'])) $_GET['type'] = "";
  1084.         if (isset($_GET['disp']) and $_GET['disp'] != "" and !preg_match("/^[0-9]+$/"$_GET['disp'])) $_GET['disp'] = "";
  1085.         /**
  1086.          * 「800-541……カテゴリページDB部分を変更したい-PC・スマホ両方」でページャーが刷新されたため、ここでのページャー生成はなくなったが、
  1087.          *
  1088.          */
  1089.         for ($i 1$i <= $data['item_count']; $i += $max_display_cnt) {
  1090.             if ($data['min_cnt'] >= $i and $data['max_cnt'] <= ($i $max_display_cnt)) {
  1091.                 $data['pager_pages_current_num'] = intval($i $max_display_cnt) + 1;
  1092.             }
  1093.         }
  1094.         // ソート用テーブル準備
  1095.         if (isset($_SESSION['order_type']) and $_SESSION['order_type'] == "1") {
  1096.             // 安い順
  1097.             for ($i 0$i $data['item_count']; $i++) {
  1098.                 $an_sort["$i"] = $data['item'][$i]['price'];
  1099.             }
  1100.             asort($an_sortSORT_NUMERIC);
  1101.         } elseif (isset($_SESSION['order_type']) and $_SESSION['order_type'] == "3") {
  1102.             // 高い順
  1103.             for ($i 0$i $data['item_count']; $i++) {
  1104.                 $an_sort["$i"] = $data['item'][$i]['price'];
  1105.             }
  1106.             arsort($an_sortSORT_NUMERIC);
  1107.         } elseif (isset($_SESSION['order_type']) and $_SESSION['order_type'] == "5") {
  1108.             // 評価・評価数の高い順
  1109.             for ($i 0$i $data['item_count']; $i++) {
  1110.                 $an_sort_tmp["$i"]['average'] = $data['item'][$i]['average'];
  1111.                 $an_sort_tmp["$i"]['review_count'] = $data['item'][$i]['review_count'];
  1112.                 $an_sort_tmp["$i"]['count'] = $i;
  1113.             }
  1114.             // 列方向の配列を得る
  1115.             foreach ($an_sort_tmp as $key => $row) {
  1116.                 $average[$key]  = $row['average'];
  1117.                 $review_count[$key] = $row['review_count'];
  1118.             }
  1119.             array_multisort($averageSORT_DESC$review_countSORT_DESC$an_sort_tmp);
  1120.             foreach($an_sort_tmp as $average_data){
  1121.                 $an_sort[$average_data['count']] = $average_data['count'];
  1122.             }
  1123.         } else {
  1124.             // 指定なし
  1125.             for ($i 0$i $data['item_count']; $i++) {
  1126.                 $an_sort["$i"] = $i;
  1127.             }
  1128.         }
  1129.         $i 0;
  1130.         foreach ($an_sort as $k => $v) {
  1131.             $an_v[$i] = $i;
  1132.             $i++;
  1133.         }
  1134.         $goodsIdList = array();
  1135.         for ($i 0$n count($data['item']); $i $n$i++) {
  1136.             $item $data['item'][$i];
  1137.             $goodsIdList[$item['goods_id']] = $item['goods_id'];
  1138.         }
  1139.         if (empty($goodsIdList)) {
  1140.             return array();
  1141.         }
  1142.         $goodsIdIn implode(','$goodsIdList);
  1143.         $res $this->GoodsService->getGoodsListByIds($goodsIdIn$data$an_v);
  1144.         return $res;
  1145.     }
  1146.     /**
  1147.      * @param string $mcName
  1148.      * @param string $ctName
  1149.      * @return string
  1150.      */
  1151.     public static function getMasterCacheKey($mcName$ctName null)
  1152.     {
  1153.         //
  1154.         if ($ctName === null) {
  1155.             //
  1156.             $masterCacheKey "main_category_index_mc_{$mcName}";
  1157.         } else {
  1158.                 //
  1159.                 $masterCacheKey "main_category_sub_mc_{$mcName}_ct_{$ctName}";
  1160.             }
  1161.         //
  1162.         $masterCacheKey str_replace('-''_'$masterCacheKey);
  1163.         //
  1164.         return $masterCacheKey;
  1165.     }
  1166.     /**
  1167.      * カテゴリページのページングに関する情報をセッションに保存する。
  1168.      *
  1169.      * @param Request $request リクエスト
  1170.      * 補足
  1171.      * CategoryService への実装を検討したが、getMainCategoryName や useUnItemOrder が
  1172.      * dynamicConverter に実装されているためここに実装。
  1173.      */
  1174.     private function setCategoryPagingSession(Request $request){
  1175.         $mc $request->attributes->get('mc');
  1176.         $ct $request->attributes->get('ct');
  1177.         /**
  1178.          * カテゴリ取得
  1179.          * カテゴリが見つからない場合はセッションをクリアして抜ける
  1180.          */
  1181.         $mainCategoryData $this->dynamicConverter->getMainCategoryName($mc);
  1182.         $isSubCategory = !is_null($ct) && $ct !== 'allitem';
  1183.         $subCategoryData $isSubCategory
  1184.             $this->dynamicConverter->getSubCategoryName($mainCategoryData['main_category_id'], $ct)
  1185.             : null
  1186.         ;
  1187.         /**
  1188.          * カテゴリが見つからない場合はセッションをクリアして抜ける
  1189.          */
  1190.         if( empty($mainCategoryData) || ($isSubCategory && empty($subCategoryData)) ){
  1191.             $this->session->remove('order_type');    // 「表示順」セッション
  1192.             return;
  1193.         }
  1194.         $mcId = (int)$mainCategoryData['main_category_id'];
  1195.         $ctId = isset($subCategoryData['category_id']) ? (int)$subCategoryData['category_id'] : null;
  1196.         // 「表示順」セッション
  1197.         $this->setCategoryOrderTypeSession($request$mcId$ctId);
  1198.     }
  1199.     /**
  1200.      * 「表示順」のセッションを設定する。
  1201.      *
  1202.      * ウェブスクレイピング(管理画面)でユニフォームネクストの商品掲載順をコピーしたカテゴリでは
  1203.      * 商品一覧を「オススメ順」として goods_recommended_order_table.display_order 順に並べる。
  1204.      * この時、フロント「表示順」に「オススメ順」が追加表示されデフォルトの並び順となる。
  1205.      * 初期表示では order_type パラメータが付かないため、order_type = 6 をセッションに保存しておく必要がある。
  1206.      *
  1207.      * ウェブスクレイピングでの掲載順コピーはカテゴリIDと商品掲載順しか管理していない(する必要がない)ため、
  1208.      * 配下カテゴリを考慮する必要はない。
  1209.      *
  1210.      * @param Request $request リクエスト
  1211.      * @param int $mcId メインカテゴリID
  1212.      * @param int|null $ctId サブカテゴリID
  1213.      */
  1214.     private function setCategoryOrderTypeSession(Request $request$mcId$ctId){
  1215.         // 「オススメ順」対応カテゴリか
  1216.         $useRecommendedOrder $this->dynamicConverter->useUnItemOrder($mcId$ctId);
  1217.         // カテゴリが「オススメ順」対応ではない場合
  1218.         if( !$useRecommendedOrder ){
  1219.             if( $this->session->has('order_type') ){
  1220.                 $this->session->remove('order_type');
  1221.             }
  1222.         }
  1223.         // カテゴリが「オススメ順」対応の場合
  1224.         else {
  1225.             // 「オススメ順」対応カテゴリで type の指定がない場合は「オススメ順」をデフォルトの表示順にする。
  1226.             if( is_null$request->get('type') ) ){
  1227.                 $this->session->set('order_type'6);
  1228.             }
  1229.             // type の指定がある場合は type を優先するためセッションをクリアする。
  1230.             else{
  1231.                 $this->session->remove('order_type');
  1232.             }
  1233.         }
  1234.     }
  1235. }