<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Customize\Controller;
use Customize\Converter\DynamicConverter;
use Customize\Entity\CacheTrait;
use Customize\Service\SearchItemService;
use Customize\Service\RecommendationService;
use Customize\Controller\LM\LmAbstractController;
use Customize\Service\CommonService;
use Customize\Service\GoodsService;
use Customize\Service\LmHelper;
use Lm\Engine\EC\Entity\GoodsWithRelated;
use Lm\Engine\EC\Entity\Item\Item;
use Lm\Entity\Goods;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Lm\Service\Db\SqlService;
use Symfony\Component\Routing\Annotation\Route;
use Customize\Converter\ProductConverter;
use Eccube\Repository\ProductRepository;
use Eccube\Common\EccubeConfig;
use Customize\Service\ReviewService;
use Customize\Service\MessageService;
use Customize\Service\RecentGoodsService;
use Customize\Service\MobileDetector as LmMobileDetector;
class ItemController extends LmAbstractController
{
use CacheTrait;
// 同一カテゴリのおすすめ表示数
const SP_RECOMMEND_ITEM_LIST_COUNT = 9;
const ITEMS_PER_PAGE = 30;
const SP_ITEMS_PER_PAGE = 10;
const MAX_PAGING_LINKS = 10;
const SP_MAX_PAGING_LINKS = 4;
/**
* @var GoodsService $goodsService
*/
protected $goodsService;
/**
* @var DynamicConverter $dynamicConverter
*/
protected $dynamicConverter;
protected $eccubeConfig;
protected $MessageService;
/**
* @var LmMobileDetector
*/
private $mobileDetector;
/**
* @var RecommendationService
*/
private $recommendationService;
public function __construct(CommonService $commonService,
LmHelper $lmHelper,
GoodsService $goodsService,
ProductRepository $productRepository,
DynamicConverter $dynamicConverter,
EccubeConfig $eccubeConfig,
ReviewService $ReviewService,
MessageService $MessageService,
RecentGoodsService $RecentGoodsService,
LmMobileDetector $mobileDetector,
RecommendationService $recommendationService
)
{
//
parent::__construct($commonService, $lmHelper);
//
$this->goodsService = $goodsService;
$this->productRepository = $productRepository;
$this->dynamicConverter = $dynamicConverter;
$this->eccubeConfig = $eccubeConfig;
$this->ReviewService = $ReviewService;
$this->MessageService = $MessageService;
$this->RecentGoodsService = $RecentGoodsService;
$this->mobileDetector = $mobileDetector;
$this->recommendationService = $recommendationService;
}
/**
* シークレットプレビュー
* @Route("/secret-preview-switch", name="secret_preview_switch", methods={"GET", "POST"})
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function secretPreviewSwitch(Request $request)
{
//
$parameters = [
'id' => $request->get('goods_id'),
];
//
return $this->redirectToRoute('item/detail', $parameters);
}
/**
* @param Request $request
* @Route("/item/{id}.html", requirements={"id" = "\S+"}, name="item/detail", methods={"GET"})
* @Route("/item/{id}/{ct1}.html", requirements={"id" = "\S+", "ct1" = "\S+"}, name="item/detail/ct1", methods={"GET"})
* @Route("/item/{id}/{ct1}/{ct2}.html", requirements={"id" = "\S+", "ct1" = "\S+", "ct2" = "\S+"}, name="item/detail/ct1/ct2", methods={"GET"})
* @Route("/item/{id}/{ct1}/{ct2}/{ct3}.html", requirements={"id" = "\S+", "ct1" = "\S+", "ct2" = "\S+", "ct3" = "\S+"}, name="item/detail/ct1/ct2/ct3", methods={"GET"})
* @Template("Item/detail.twig")
*/
public function detail(Request $request, $_route, $id, $ct1 = null, $ct2 = null, $ct3 = null)
{
//
$request->attributes->set('_route', 'item/detail');
//
$params = compact('id', 'ct1', 'ct2', 'ct3');
$queries = $request->query->all();
$params += $queries;
// 品番URLの相互リダイレクト判定
if (($canonicalId = $this->goodsService->getGoodsRoutingMap($id)) !== false) {
//
$params['id'] = $canonicalId;
//
return $this->redirectToRoute($_route, $params);
}
// 商品IDの取得
if (($mappedGoodsId = $this->goodsService->getGoodsRoutingByHinban($id)) !== false) {
// 品番URL
$goodsId = $mappedGoodsId;
} elseif (is_numeric($id)) {
// 通常URL
$goodsId = $id;
} else {
// 商品IDが不正
throw new NotFoundHttpException();
}
// 商品IDを記憶
$goodsId = (int)$goodsId;
$request->attributes->set('goodsId', $goodsId);
// バリデーション
try {
if (!($goods = new GoodsWithRelated($goodsId))) {
// 商品が見つからない
throw new NotFoundHttpException('商品が見つかりません');
} else if (!empty($goods->getGoodsDdate())) {
// 商品が削除済み
throw new NotFoundHttpException('削除済みの商品です');
} else if ($goods->getGoodsStatus() === Goods::GOODS_STATUS_UNAVAIABLE){
// 非表示商品
if (!LmHelper::isSecret()) {
// シークレットプレビュー不可
throw new NotFoundHttpException('商品を閲覧する権限がありません');
}
}
} catch (\Exception $e) {
throw new NotFoundHttpException($e->getMessage(), $e);
}
// 複製商品
$mc = null;
$mcMcWebName = null;
$mcWebName = null;
$ctWebName = null;
if (!empty($ct1) || !empty($ct2) || !empty($ct3)) {
if (!empty($ct1) && !empty($ct2) && !empty($ct3)) {
//
if ($mc = $this->goodsService->isBelongsToMcMcCt($goodsId, $ct1, $ct2, $ct3)) {
// 配下親カテゴリ/親カテゴリ/子カテゴリ
// 本番環境: https://www.l-m.co.jp/item/11-8035/work/burtle/aw.html
// 検証環境: https://stg.l-m.co.jp/item/11-8035/work/burtle/aw.html
// 開発環境: https://eccube.l-m.local/item/11-8035/work/burtle/aw.html
$mcMcWebName = $ct1;
$mcWebName = $ct2;
$ctWebName = $ct3;
}
} else if (!empty($ct1) && !empty($ct2)) {
//
if ($mc = $this->goodsService->isBelongsToMcMc($goodsId, $ct1, $ct2)) {
// 配下親カテゴリ/親カテゴリ
// 本番環境: https://www.l-m.co.jp/item/11-8035/work/burtle.html
// 検証環境: https://stg.l-m.co.jp/item/11-8035/work/burtle.html
// 開発環境: https://eccube.l-m.local/item/11-8035/work/burtle.html
$mcMcWebName = $ct1;
$mcWebName = $ct2;
} else if ($mc = $this->goodsService->isBelongsToMcCt($goodsId, $ct1, $ct2)) {
// 親カテゴリ/子カテゴリ
// 本番環境: https://www.l-m.co.jp/item/27-00141NVP/polo/gekiyasu.html
// 検証環境: https://stg.l-m.co.jp/item/27-00141NVP/polo/gekiyasu.html
// 開発環境: https://eccube.l-m.local/item/27-00141NVP/polo/gekiyasu.html
$mcWebName = $ct1;
$ctWebName = $ct2;
}
} else if (!empty($ct1)) {
//
if ($mc = $this->goodsService->isBelongsToMc($goodsId, $ct1)) {
// 配下親カテゴリ
// 本番環境: https://www.l-m.co.jp/item/11-8035/work.html
// 検証環境: https://stg.l-m.co.jp/item/11-8035/work.html
// 開発環境: https://eccube.l-m.local/item/11-8035/work.html
// 親カテゴリ
// 本番環境: https://www.l-m.co.jp/item/27-00141NVP/polo.html
// 検証環境: https://stg.l-m.co.jp/item/27-00141NVP/polo.html
// 開発環境: https://eccube.l-m.local/item/27-00141NVP/polo.html
// 親カテゴリ(親カテのみ)
// 本番環境: https://www.l-m.co.jp/item/27-00141NVP/election-item.html
// 検証環境: https://stg.l-m.co.jp/item/27-00141NVP/election-item.html
// 開発環境: https://eccube.l-m.local/item/27-00141NVP/election-item.html
$mcWebName = $ct1;
}
}
//
if (empty($mcMcWebName) && empty($mcWebName) && empty($ctWebName)) {
// 複製商品URLが不正
throw new NotFoundHttpException();
}
}
//
$device = strtolower($this->CommonService->GetDevice());
// 「非表示商品」※社内限定
$is_secret = LmHelper::isSecret();
//
$masterCacheKey = self::getMasterCacheKey($goodsId);
// 絞込み対応(SESSION内の検索条件をキャッシュIDのサフィックス生成要素に加える)
$suffix = (function($mcMcWebName, $mcWebName, $ctWebName) {
//
$_params = compact('mcMcWebName', 'mcWebName', 'ctWebName');
//
return !empty($_params) ? hash('sha256', base64_encode(serialize($_params))) : '';
})($mcMcWebName, $mcWebName, $ctWebName);
//
$viewCacheKey = "{$masterCacheKey}__{$device}_view__{$suffix}";
//
$masterCache = $this->handleMasterCache($masterCacheKey, $device, [
$viewCacheKey,
]);
// 最近チェックした商品(cookie)
//$useCache = false;
$cookies=$this->RecentGoodsService->getRecentList($goodsId);
$recentviews = array();
if(!empty($cookies)){
$recentviews=$this->RecentGoodsService->LM_getRecentViews2($cookies);
}
//
return array_merge($this->getCacheByKey($viewCacheKey, function () use ($request, $goods, $is_secret, $mc, $mcMcWebName, $mcWebName, $ctWebName) {
//
return $this->_detail($request, $goods, $is_secret, $mc, $mcMcWebName, $mcWebName, $ctWebName);
}), [
'recentviews' => $recentviews,
]);
}
/**
* @param Request $request
* @param GoodsWithRelated $goods 商品エンティティ
* @param bool $is_secret
* @param null|array $mc 親カテゴリ情報
* @param null|string $mcMcWebName 配下親カテゴリURL
* @param null|string $mcWebName 親カテゴリURL
* @param null|string $ctWebName 子カテゴリURL
* @return array
*/
public function _detail(Request $request, Goods $goods, $is_secret, $mc = null, $mcMcWebName = null, $mcWebName = null, $ctWebName = null)
{
//
$id = $goods->getGoodsId();
//
$parameters = array_merge($this->__detail($request, $id, $is_secret, $mc, $mcMcWebName, $mcWebName, $ctWebName), [
'goods' => $goods,
'goods_name_with_vending_status' => $goods->getVendingStatusLabel()->isShowLabel() ? "[{$goods->getVendingStatusLabel()->getLabel()}]{$goods->getGoodsName()}" : $goods->getGoodsName(),
'back_to_top_link' => $goods->getGoodsName() . str_replace("品番", "", $goods->getGoodsMainKataban()),
]);
//
return $parameters;
}
/**
* @param Request $request
* @param int $id 商品ID
* @param bool $is_secret シークレットプレビュー
* @param null|array $mc 親カテゴリ情報
* @param null|string $mcMcWebName 配下親カテゴリURL
* @param null|string $mcWebName 親カテゴリURL
* @param null|string $ctWebName 子カテゴリURL
* @return array
*/
public function __detail(Request $request, $id, $is_secret, $mc = null, $mcMcWebName = null, $mcWebName = null, $ctWebName = null)
{
// バリデーション
if (($data = $this->goodsService->getGoodsById($id)) === false) {
// 商品が見つからない
throw new NotFoundHttpException();
}
$Product = $this->productRepository->find($id);
$productConverter = new ProductConverter();
//
// if ($data['goods_set_purchase_flg'] == 1) {
// var_dump(compact('color', 'size', 'stock'));
// exit;
// }
// 色情報
$color = $this->goodsService->getGoodsColorSelectSql($id);
// サイズ情報
$size = $this->goodsService->getGoodsSizeListById($id);
// 商品予約情報
$isYoyakuAvailable = $this->goodsService->getGoodsReservation($id);
// 商品即日情報
$sokujitsu = $this->goodsService->getGoodsSameDayShipping($id,1);
//即日バナー表示チェック
$sokujitsu = !empty($sokujitsu) ? $sokujitsu : [];
$sokujitsu['type'] = 0;
$shiiresaki = $productConverter->getShiiresakiById($data['goods_shiiresaki']);
$result = $this->goodsService->getGoodsSameDayShipping($id);
if ($result) {
$sokujitsu['type'] = json_encode($result);
//即日の発注締め時刻
if ($sokujitsu['type'] == 1) {
$imgPath = "/images/itempage/chokusou/";
$imgPath2 = "/images/itempage/chokusou/";
$sokujitsu['timeLimit'] = substr($shiiresaki['shiiresaki_shimekiri_time'], strpos($shiiresaki['shiiresaki_shimekiri_time'], ' ') + 1, 2);
$sokujitsu['img1'] = $imgPath . "banner{$data['goods_shiiresaki']}_s.webp";
$sokujitsu['img2'] = $imgPath . "banner{$data['goods_shiiresaki']}_sc.webp";
$sokujitsu['img3'] = $imgPath2 . "banner{$data['goods_shiiresaki']}.webp";
} elseif ($sokujitsu['type'] == 2) {
$imgPath = "/images/itempage/sokujitsu/";
$sokujitsu['timeLimit'] = "16";
$sokujitsu['img1'] = $imgPath . "sokujitsu-mini-itempage.webp";
$sokujitsu['img2'] = $imgPath . "sokujitsu-mini-itempage.webp";
$sokujitsu['img3'] = $imgPath . "sokujitsu-itempage.webp";
}
}
$newTagList = $this->dynamicConverter->getListByGoodsId(1, $id);
// TODO: 新商品説明に入力があるか判定
$useNewItemDescription = false;
$rs = $this->dynamicConverter->getGoodsKatabanSelect($id);
$kataban = '';
if (isset($rs)) {
$tmpRow = 0;
foreach ($rs as $row) {
$tmpRow++;
if ($tmpRow > 1) {
$kataban .= ",";
} else {
$kataban .= "品番";
}
$kataban .= $row['gp_kataban'];
}
}
// TODO: hinbanStr 品番取得
$hinbanStr = '';
$hinbanArr = explode(',', str_replace("品番", "", $kataban));
foreach ($hinbanArr as $idx => $hinban) {
if ($val = mb_strstr($hinban, '-', false)) {
$hinbanStr .= str_replace('-', '', $val);
} else {
$hinbanStr .= $hinban;
}
if ($idx != count($hinbanArr) - 1) $hinbanStr .= ',';
}
// 新商品説明
$newDescriptionColors = null;
if(
(!is_null($data['goods_new_description']) && $data['goods_new_description'] !== '') ||
(!is_null($data['goods_new_material']) && $data['goods_new_material'] !== '') ||
(!is_null($data['goods_new_spec']) && $data['goods_new_spec'] !== '') ||
(!is_null($data['goods_new_annotation']) && $data['goods_new_annotation'] !== '') ||
(!is_null($data['goods_new_name']) && $data['goods_new_name'] !== '') ||
(!is_null($data['goods_new_maker']) && $data['goods_new_maker'] !== '')
){
$useNewItemDescription = true;
$rs = $this->dynamicConverter->getGoodsColorSelect($id);
if (isset($rs)) {
$color_array = array();
foreach ($rs as $row) {
$color_array[] = $row['color_name'];
}
$newDescriptionColors = implode('、', $color_array);
}
}
// TODO: 関連商品一覧
//$displayRelative = "";
//お客様の声
list($messages, $messagesTotal) = $this->MessageService->getCustomerMessagesAndCount($id, 1);
$messages = $this->MessageService->formatCustomerMessages($messages);
// TODO: 下部ボタン
$ct = $_GET['ct'] ?? '';
$mc = $_GET['mc'] ?? '';
$get_parameter = $this->createGetParamater($_GET);
// 大フッター(商品)
$largeFooterList = $this->dynamicConverter->getLargeFooterListByGoodsId(1, $id);
// TODO: フッターリンク(カテゴリ)
$canonicalPankuzuMainCategory = [];
// TODO: フッタ2
$pagebottomCache = null;
// TODO: 上部差込み
$SET_GOODS_DETAIL_TOP_SASHIKOMI_COUNT = 31;
$ItemSashikomiImageModel = [
'TYPE_BASE_01' => 'base_01',
'WEARING_IMAGE_MAX_COUNT' => 4,
'TYPE_HANGER_ILLUST' => 'hanger_illust',
'TYPE_FABRIC' => 'fabric',
'TYPE_UPPER' => 'upper',
'TYPE_MID_SOLE' => 'mid_sole',
'TYPE_OUT_SOLE' => 'out_sole',
'TYPE_DETAIL_FRONT_BACK' => 'detail_front_back',
'TYPE_DETAIL_COLUMN' => 'detail_column',
'TYPE_MODEL_MENS' => 'model_mens',
'TYPE_MODEL_LADIES' => 'model_ladies',
'TYPE_BASE_03' => 'base_03',
'TYPE_COLOR_VARIATION' => 'color_variation',
'TYPE_COLORUP' => 'colorup',
'TYPE_SIZE_SILHOUETTE' => 'size_silhouette',
'TYPE_POCKET_SIZE_AREA' => 'pocket_size_area',
'TYPE_PRINT_AREA' => 'print_area'
];
//$CFIMG_DOMAIN = "img0.land-mark.biz";
//$CFIMG_URL = "https://{$CFIMG_DOMAIN}/ut_img/";
$show_sashikomi_target_gender_src = 'public_images/categorypage/banner/work/work-ss-hayawari-itempage-1col.jpg';
$show_sashikomi_target_gender_alt = '';
// 性別表記の差し込み画像
$target_gender_image = array(
"",
"itempage/805px/caution/mens-item.jpg",
"itempage/805px/caution/ladies-item.jpg",
"itempage/805px/caution/unisex-item.jpg",
"itempage/805px/caution/kids-item.jpg",
);
$target_gender_image_alt = array(
"",
"この商品は男性用です",
"この商品は女性用です",
"この商品は男女兼用です",
"この商品は子ども用です",
);
if (isset($data['goods_target_gender'])) {
$target_gender_id = $data['goods_target_gender'] ?: 0;
$show_sashikomi_target_gender_src = $target_gender_image[$target_gender_id];
$show_sashikomi_target_gender_alt = $target_gender_image_alt[$target_gender_id];
}
$goodsSeriesList = $this->dynamicConverter->getGoodsSeriesListByGoodsId($id);
$sashikomi_image_info_map = $this->dynamicConverter->getSashikomiImageInfoMap($id);
//TODO: プリント
$breadCrumbCategoryName2 = $data['goods_breadcrumb_category_name2'];
//サイズ表
list($SizeList,$SizePosition) = $this->dynamicConverter->LM_displaySizeMatrix_cross2($id);
$goods_name_with_vending_status = '';
$mainImage = $this->dynamicConverter->getGoodsImage($id,$data['goods_name']);
list($mainUrl,$mainUrlSum,$comment) = $mainImage;
$thumbCount = 0;
$is_preview_mode = false;
$displayTeika = $this->dynamicConverter->LM_displayteika_new($id);
$displayPrice = $this->dynamicConverter->LM_displayPriceList3($id); // 販売価格
$displayPrice2 = "";
if (isset($displayPrice['mi']) and isset($displayPrice['ma']) and $displayPrice['mi'] != $displayPrice['ma']) {
$displayPrice2 = number_format($displayPrice['mi']) . '円~' . number_format($displayPrice['ma']).'円(税込)';
}
$isShowLeftmenu = true;
//$mainUrlSum = "";
define("_VIEW_ITEM_DETAIL_FLAG_" . $data['goods_id'], "on");
$lm_displayHosokuSetsumei2 = $this->LM_displayHosokuSetsumei2($data);
$REQUEST_URI = '';
$displayShoppingCart = "";
$DISPLAY_LINES = 6;
$partialCounter = "";
$partialCounter = mb_convert_kana($partialCounter, 'A');
$isDisplaySetCoo = true;
/*
$goodsSetCooList = [
[
'data' => $data,
'displayTeika' => $displayTeika,
'displayPrice' => $displayPrice,
'displayPrice2' => $displayPrice2,
'mainUrl' => $mainUrl,
'mainUrlSum' => $mainUrlSum,
'comment' => $comment,
'useCache' => $useCache,
'is_preview_mode' => $is_preview_mode,
'isShowLeftmenu' => $isShowLeftmenu,
'is_secret' => $is_secret,
'displayOther' => $displayOther,
'thumbCount' => $thumbCount,
'displayShoppingCart' => $displayShoppingCart,
'DISPLAY_LINES' => $DISPLAY_LINES,
'breadCrumb' => $breadCrumb,
]
];
*/
// SPページ Commonデータ取得
$custom_menu = $this->dynamicConverter->getMenuGroup($this->eccubeConfig['EditSpMenu']['MENU_NAME_COMMON'], $this->eccubeConfig['EditSpMenu']['BOOL_TRUE']);
$custom_frequently_searched_word = $this->dynamicConverter->getSearchWordGroup($this->eccubeConfig['EditSpMenu']['MENU_NAME_COMMON'], $this->eccubeConfig['EditSpMenu']['BOOL_TRUE']);
// コーディネート
$coItemList = [];
$tempRow = $this->dynamicConverter->getSearchCoordinate($id);
if (isset($tempRow) && sizeof($tempRow) > 0) {
$goods_design_coo = $tempRow[0]['goods_design_coo'];
$coItemList = $this->dynamicConverter->getCoosData($goods_design_coo);
$coItemList = empty($coItemList) ? [] : $coItemList;
}
// ⑳【LM】売れ筋商品一覧(SP)
$mcName = $request->get('mcName');
$ctName = $request->get('ctName');
$mcId = $request->get('mcId');
$ctId = $request->get('ctId');
$isOnlyMain = false;
if (isset($mcName) && $mcName != '') {
$categoryParam = array(
'mc' => $mcName,
'ct' => $ctName,
);
} else {
if (!empty($breadCrumb[1])) {
$matches = array();
if (preg_match('/^(?:https?:\/\/)?(?:www\.)?(?:l-m\.co\.jp)?(?:\/)?([^\/]+)(?:\/)?([^\/]+)?/', $breadCrumb[1]['href'], $matches)) {
$categoryParam = array();
if (!empty($matches[1])) {
$categoryParam['mc'] = $matches[1];
}
if (!empty($matches[2])) {
$categoryParam['ct'] = $matches[2];
} else{
$categoryParam['ct'] = 'allitem';
}
}
} else if (!empty($mct)) {
$categoryParam = array(
'mc' => $mct,
'ct' => 'allitem',
);
}
}
$breadCrumb = $this->dynamicConverter->getBreadCrumbsByGoodsId($id);
$popularData = "";
$category_data = [];
if (!empty($categoryParam)) {
$tempRow = $this->dynamicConverter->getMainCategoryNameSelect($categoryParam['mc']);
if (isset($tempRow)) {
$mcId = $tempRow[0]['main_category_id'];
$mcName = $categoryParam['mc'];
$isOnlyMain = (int)$tempRow[0]['category_group_only_main'] === 1;
if ($categoryParam['ct'] == "allitem") {
$ctId = "allitem";
$ctName = "allitem";
} elseif (isset($categoryParam['ct']) and $categoryParam['ct'] != "") {
$tempRow = $this->dynamicConverter->getSubCategoryNameSelect($mcId, $categoryParam['ct']);
if (isset($tempRow)) {
$ctId = $tempRow[0]['category_id'];
$ctName = $categoryParam['ct'];
}
}
}
$popularData = $this->dynamicConverter->getPopularityItemLIstByMainCategoryId2($mcId, $is_secret, self::SP_RECOMMEND_ITEM_LIST_COUNT + 1);
foreach( $popularData as $idx => $item_data){
if((string)$item_data['goods_id'] === (string)$id){
unset($popularData[$idx]);
break;
}
}
$popularData = array_slice($popularData, 0, self::SP_RECOMMEND_ITEM_LIST_COUNT);
if ($categoryParam['ct'] == 'allitem' && $categoryParam['mc'] != '') {
$tempRow = $this->dynamicConverter->getSearchAllCategory($categoryParam['mc']);
if (isset($tempRow) && sizeof($tempRow) > 0) {
$category_data = $tempRow[0];
}
} else if ($categoryParam['ct'] != '' && $categoryParam['mc'] != '') {
$tempRow = $this->dynamicConverter->getSearchGoodsImage($categoryParam['mc'], $categoryParam['ct']);
if (isset($tempRow) && sizeof($tempRow) > 0) {
$category_data = $tempRow[0];
}
} else if ($categoryParam['mc'] != '') {
$tempRow = $this->dynamicConverter->getSearchCategory($categoryParam['mc']);
if (isset($tempRow) && sizeof($tempRow) > 0) {
$category_data = $tempRow[0];
}
} else {
$category_data = $data;
}
} else {
$popularData = $this->recommendationService->getRecommendationList($breadCrumb[0]['label'], self::SP_RECOMMEND_ITEM_LIST_COUNT);
}
// 当商品の掲載カテゴリ//////////////////////////////////////////////////////////////////
$displayCategory = '';
// 商品カテゴリの判定
if (!empty($mcId)) {
$mct = $this->dynamicConverter->getMainCategoryWebnameByMcId($mcId);
} else {
// 800-172「当商品の掲載カテゴリ」と「パンくず(※canonicalのURLの場合は一番掲載の多い親カテゴリを表示する)」の処理
$mct = $this->dynamicConverter->detectMainCategory($id);
}
$additionalList = $this->dynamicConverter->getMainCategorySqlFromGoodsId2($id);
$is_except_supersale = true;
if (!$this->mobileDetector->isMobile()
&& empty($additionalList)
&& ($mct == 'work' || $mct == 'jimufuku' || $mct == 'medical-hakui')
) {
$displayCategory = $this->dynamicConverter->LM_displayCategory($id, $is_except_supersale);
$DISPLAY_LINES = 6;
} else {
$displayCategory = $this->dynamicConverter->LM_displayCategory4($id, $mct, $additionalList, $is_except_supersale);
$DISPLAY_LINES = 99;
}
$canonicalPankuzuMainCategory = $displayCategory['canonicalPankuzuMainCategory'];
$displayCategory = $displayCategory['viewStr'];
//パンくず//////////////////////////////////////////////////////////////////////////////
// 2023.07.28 取得した変数が利用されていないため、処理を全てコメントアウトする
/*
if (!empty($mcId)) {
$result = $this->dynamicConverter->getCategoryData($mcId,$ctId);
$urlCategory = array_shift($result);
}
// パンくずセット
// TODO: 相関エンティティに移植
$snipetCategory = $canonicalPankuzuMainCategory[0]['main_name'];
*/
//パンくずEND//////////////////////////////////////////////////////////////////////////////
// TODO: ⑪【LM】在庫一覧(SP)
$reviewTotal = 10;
$average = 4.5;
$teika = $this->dynamicConverter->LM_displayteika_new($id, true);
/*
//SP商品詳細色
$colors = [
[
'gcl_id' => 97964,
'color_name' => "カラー1",
'color_rgb' => "#ffcc88",
'color_num' => 1
],
[
'gcl_id' => 97965,
'color_name' => "カラー2",
'color_rgb' => "#ffcc88",
'color_num' => 2
],
[
'gcl_id' => 97966,
'color_name' => "カラー3",
'color_rgb' => "#ffcc88",
'color_num' => 3
],
[
'gcl_id' => 97967,
'color_name' => "カラー4",
'color_rgb' => "#ffcc88",
'color_num' => 4
],
[
'gcl_id' => 97968,
'color_name' => "カラー5",
'color_rgb' => "#ffcc88",
'color_num' => 5
],
[
'gcl_id' => 98125,
'color_name' => "カラー6",
'color_rgb' => "#ffcc88",
'color_num' => 6
],
];*/
//TODO: カート情報
$goods_color_size_stock_list = $this->dynamicConverter->getStockList($id);
$stockNyukayoteiList = [];
if (!empty($goods_color_size_stock_list)) {
foreach ($goods_color_size_stock_list as $goods_color_size_stock) {
// 在庫確認
$gcl_id = $goods_color_size_stock['gcl_id'];
$gp_id = $goods_color_size_stock['gp_id'];
$chokusouFlg = "";
$chokusouFlg = $this->dynamicConverter->LM_chokusouCheck($id, $gcl_id, $gp_id);
$stock_row = $goods_color_size_stock;
$stock = 0;
if (!is_numeric($stock_row['stock'])) {
$stock = $stock_row['stock'];
} else {
$stock = $stock_row['stock']+intval($stock_row['jan_stock3'])+intval($stock_row['jan_stock4'])+intval($stock_row['jan_stock5'])+intval($stock_row['jan_stock6'])+intval($stock_row['jan_stock7'])+intval($stock_row['jan_stock8'])+intval($stock_row['jan_stock9']);
if(intval($stock_row['jan_stock3'])>0 and $stock_row['jan_stock3_nyuka_date']==""){
$stock .= " (即日発送 ".intval($stock_row['jan_stock3']).")";
}elseif(intval($stock_row['jan_stock3'])>0 and $stock_row['jan_stock3_nyuka_date']!=""){
$stock .= '<div class="nyuka-yotei" style="font-size:12px;">入荷予定日<br />' . date("n月j日", strtotime($stock_row['jan_stock3_nyuka_date']." +1 day")) . '</div>';
$stockNyukayoteiList[$stock_row['jan_color']][$stock_row['jan_price']] = date("n月j日", strtotime($stock_row['jan_stock3_nyuka_date']." +1 day"));
}elseif($chokusouFlg==1){
$stock .= " (即日発送 ".intval($stock).")";
}
}
$stockList[$gcl_id][$gp_id] = $stock;
if ($stock_row['keppin']) {
$stockKeppinList[$gcl_id][$gp_id] = true;
} else {
$stockKeppinList[$gcl_id][$gp_id] = false;
}
}
}
$stockList = !empty($stockList) ? $stockList : [];
$stockKeppinList = !empty($stockKeppinList) ? $stockKeppinList : [];
$holidayRecord = $this->dynamicConverter->getIsHoliday();
$nowtime = time();
// 営業時間
$businessHourFromTime = strtotime( date('Y-m-d '.$this->lmHelper->getConfig('BUSINESS_HOUR_FROM_TIME'), $nowtime) );
$businessHourToTime = strtotime( date('Y-m-d '.$this->lmHelper->getConfig('BUSINESS_HOUR_TO_TIME'), $nowtime) );
if( count($holidayRecord) > 0 ) {
$isOutOfService = true;
}
else if( $nowtime < $businessHourFromTime || $nowtime > $businessHourToTime ){
$isOutOfService = true;
}
else{
$isOutOfService = false;
}
$goods_set_purchase_list = $this->dynamicConverter->getGoodsSetPurchaseList($id);
$canonicalHinban = $data['goods_canonical_hinban'];
$item_id = !empty($canonicalHinban) ? $canonicalHinban : $data['goods_id'];
$rs = $this->dynamicConverter->getJanShireColorData($id);
$color_number_map = [];
if (isset($rs)) {
foreach($rs as $row){
$color_number_map[ $row['jan_color'] ] = is_null($row['jan_shiire_color']) ? '' : $row['jan_shiire_color'];
}
}
$goods_set_map = $this->dynamicConverter->convertGoodsSetPurchaseListToMap($goods_set_purchase_list);
//
$item = new Item($id);
// お客様からの口コミレビュー ///////////////////////////////////////////////////////////////
$allReviews = $this->ReviewService->GetReview($id, $reviewCount, null);
$reviewAdd = array('average'=>0,'star'=>0,'count'=>0,'hasMoreReview'=>0);
if(!empty($allReviews)){
$cr_points = array_map(function ($v) {
return $v["cr_points"];
}, $allReviews);
$reviewAdd['count'] = $reviewCount;
$reviewAdd['hasMoreReview'] = $this->lmHelper->getConfig('ITEM_PAGE_REVIEW_LIMIT');
$arg= array_sum($cr_points) / count($cr_points);
$reviewAdd['average'] = (floor($arg * 10)) / 10;
$reviewAdd['star'] = ((int)($arg * 2) / 2) * 10;
}
$review = array_slice($allReviews, 0, $this->lmHelper->getConfig('ITEM_PAGE_REVIEW_LIMIT'));
// お客様からの口コミレビューEND/////////////////////////////////////////////////////////////
$this->dataLayer['gdn']['items'][] = $this->CommonService->get_google_retargeting_item($id);
$this->dataLayer['ydn']['yahoo_retargeting_items'][] = $this->CommonService->get_yahoo_retargeting_item($id);
$this->dataLayer['criteo']['item'] = $id;
$imgrow="";
$isMobile = $this->mobileDetector->isMobile();
if (!$isMobile) {
if (!empty($data['goods_bottom_sashikomi'])) {
$data['goods_bottom_sashikomi'] = str_replace('/805px/work/itempage-work-hot-inner.jpg"', '/805px/work/itempage-work-hot-inner.jpg" width="805px" height="150px"', $data['goods_bottom_sashikomi']);
}
}
$koeCategory = array(
1 => "Tシャツ",
2 => "アロハシャツ",
3 => "エステユニフォーム",
4 => "エプロン",
5 => "キャップ",
6 => "キャップ/ハット",
7 => "コックコート",
8 => "シャツ",
9 => "ジャンパー",
10 => "ジャージ",
11 => "スウェット",
12 => "スカート",
13 => "スクラブ",
14 => "チュニック",
15 => "ツナギ服",
16 => "トレーナー",
17 => "ネクタイ",
18 => "ハッピ",
19 => "バッグ",
20 => "バンダナ",
21 => "パンツ",
22 => "パーカー",
23 => "ベスト",
24 => "ポロシャツ",
25 => "ワンピース",
26 => "作業服",
27 => "医療",
29 => "安全靴",
30 => "白衣",
31 => "防寒服"
);
$koeCategoryName = $canonicalPankuzuMainCategory[0]["main_name"] ?? null;
$koeCategoryId =array_search($koeCategoryName, $koeCategory);
return [
'data' => $data,
'newTagList' => $newTagList,
'useNewItemDescription' => $useNewItemDescription,
'hinbanStr' => $hinbanStr,
'newDescriptionColors' => $newDescriptionColors,
//'displayRelative' => $displayRelative,
'displayCategory' => $displayCategory,
//'useCache' => $useCache,
//'recentviewsSwitch' => $recentviewsSwitch,
'ct' => $ct,
'mc' => $mc,
'get_parameter' => $get_parameter,
'is_secret' => $is_secret,
'largeFooterLis' => $largeFooterList,
'canonicalPankuzuMainCategory' => $canonicalPankuzuMainCategory,
'pagebottomCache' => $pagebottomCache,
'SET_GOODS_DETAIL_TOP_SASHIKOMI_COUNT' => $SET_GOODS_DETAIL_TOP_SASHIKOMI_COUNT,
'ItemSashikomiImageModel' => $ItemSashikomiImageModel,
'sashikomi_image_info_map' => $sashikomi_image_info_map,
//'CFIMG_URL' => $CFIMG_URL,
//'directFlg' => $directFlg,
//'CFIMG_DOMAIN' => $CFIMG_DOMAIN,
//'chokusouOrderDeadline' => $chokusouOrderDeadline,
'show_sashikomi_target_gender_alt' => $show_sashikomi_target_gender_alt,
'show_sashikomi_target_gender_src' => $show_sashikomi_target_gender_src,
'goodsSeriesList' => $goodsSeriesList,
'kiji_thickness_list'=> $this->lmHelper->getConfig('KIJI_THICKNESS_LIST'),
'kiji_hardness_list' => $this->lmHelper->getConfig('KIJI_HARDNESS_LIST'),
'kiji_stretch_list' => $this->lmHelper->getConfig('KIJI_STRETCH_LIST'),
'breadCrumbCategoryName2' => $breadCrumbCategoryName2,
'SizeList' => $SizeList,
'SizePosition' => $SizePosition,
'breadCrumb' => $breadCrumb,
'BreadCrumbs' => $breadCrumb,
'messages' => $messages,
'messagesTotal' => $messagesTotal,
'goods_name_with_vending_status' => $goods_name_with_vending_status,
'mainUrl' => $mainUrl,
'comment' => $comment,
'thumbCount' => $thumbCount,
'is_preview_mode' => $is_preview_mode,
'displayTeika' => $displayTeika,
'displayPrice' => $displayPrice,
'displayPrice2' => $displayPrice2,
'isShowLeftmenu' => $isShowLeftmenu,
'displayTogether' => $this->ReviewService->LM_displayTogetherBuyDetail_new3($id),
//'LOGIN' => $LOGIN,
//'displayZaiko' => $displayZaiko,
//'sendDate' => $sendDate,
//'displayOther' => $displayOther,
'mainUrlSum' => $mainUrlSum,
'lm_displayHosokuSetsumei2' => $lm_displayHosokuSetsumei2,
'REQUEST_URI' => $REQUEST_URI,
'displayShoppingCart' => $displayShoppingCart,
'DISPLAY_LINES' => $DISPLAY_LINES,
'partialCounter' => $partialCounter,
'isDisplaySetCoo' => $isDisplaySetCoo,
//'goodsSetCooList' => $goodsSetCooList,
'custom_menu' => $custom_menu,
'custom_frequently_searched_word' => $custom_frequently_searched_word,
'review' => $review,
'reviewAdd'=>$reviewAdd,
'coItemList' => $coItemList,
'popularData' => $popularData,
'category_data' => $category_data,
'mcId' => $mcId,
'mcName' => $mcName,
'ctId' => $ctId,
'ctName' => $ctName,
'imgrow' => $imgrow,
'reviewTotal' => $reviewTotal,
'average' => $average,
'teika' => $teika,
//'sizeData' => $sizeData,
//'sizeNameList' => $sizeNameList,
//'sizeData2' => $sizeData2,
//'sizecomments' => $sizecomments,
'isOutOfService' => $isOutOfService,
'stockList' => $stockList,
'stockKeppinList' => $stockKeppinList,
'goods_set_purchase_list' => $goods_set_purchase_list,
'item' => $item,
'item_id' => $item_id,
'stockNyukayoteiList' => $stockNyukayoteiList,
'color_number_map' => $color_number_map,
'goods_set_map' => $goods_set_map,
'sokujitsu' => $sokujitsu,
//'Category1' => $category1,
//'Category1_price' => $category1_price,
//'Category2' => $category2,
//'ProductClass' => $productClasses,
'Product' => $Product,
'size' => $size,
'color' => $color,
'MetaTags' => ['item'=>$data], #2022/08/08 kawai
'dataLayer' => $this->dataLayer,
'isYoyakuAvailable' => $isYoyakuAvailable,
'isMobile' => $isMobile,
'koeCategoryName' => $koeCategoryName,
'koeCategoryId' => $koeCategoryId,
];
}
/**
* @param Request $request
* #Route("/item/friend", name="item/friend", methods={"GET"})
* @Template("Item/friend.twig")
*/
public function friend(Request $request)
{
//
if (!($goodsId = $request->get('id'))) {
throw new NotFoundHttpException();
}
//
$sql = new SqlService();
$data = $sql->Table('goods_table')
->Set('goods_id', $goodsId)
->Find();
//
return [
'data' => $data,
];
}
/**
* @param Request $request
* @return mixed
* @Route("/item/searchlist", name="item_searchlist", methods={"GET", "POST"})
* @Template("Item/searchlist.twig")
*/
public function searchlist(Request $request, SearchItemService $searchItemService)
{
//
$isMobile = $this->mobileDetector->isMobile();
$searchtext = $request->get('searchtext');
$orderType = $request->get('orderType');
$page = $request->get('page', 1);
$itemsPerPage = $request->get('items-per-page', $isMobile ? self:: SP_ITEMS_PER_PAGE : self::ITEMS_PER_PAGE);
$maxPagingLinks = $request->get('max-paging-links', $isMobile ? self:: SP_MAX_PAGING_LINKS : self::MAX_PAGING_LINKS);
$params = $request->query->all();
//
$BreadCrumbs = [
[
'label' => "「{$searchtext}」の検索結果一覧",
],
];
//
$resultList = $searchItemService->searchItemList($searchtext, $itemsPerPage, $itemsPerPage * ($page - 1), $resultCount, $orderType);
$pager = LmHelper::paging($page, $resultCount, $itemsPerPage, $maxPagingLinks, $params);
//
if (($resultCount === 1) && ($item = $resultList[0])) {
//
return $this->redirectToRoute('item/detail', ['id' => $item['goods_canonical_hinban'] ?? $item['goods_id'] ]);
} else {
//
$this->dataLayer['gdn']['items'] = array_map(function ($id) {
return $this->CommonService->get_google_retargeting_item($id);
}, array_column(array_slice($resultList, 0, 3), 'goods_id'));
$this->dataLayer['ydn']['yahoo_retargeting_items'] = array_map(function ($id) {
return $this->CommonService->get_yahoo_retargeting_item($id);
}, array_column(array_slice($resultList, 0, 3), 'goods_id'));
$this->dataLayer['criteo']['item'] = array_column(array_slice($resultList, 0, 3), 'goods_id');
//
return [
'BreadCrumbs' => $BreadCrumbs,
'searchtext' => $searchtext,
'resultCount' => $resultCount,
'resultList' => $resultList,
'pager' => $pager,
'isMobile' => $isMobile,
'dataLayer' => $this->dataLayer,
];
}
}
/**
* @param Request $request
* #Route("/item/suggest", name="item_suggest", methods={"GET"})
* @Template("Item/suggest.twig")
*/
public function suggest(Request $request)
{
//
// パラメータの解析
$searchtext = $request->get('searchtext');
$display_max = $request->get('display_max', 0);
//
$keywords = str_replace(' ', ' ', $searchtext);
$keywords = preg_split('/[ ]+/', $keywords);
// キーワードサジェスト
$keywords = (array)$searchtext;
//
// // カテゴリサジェスト
// $categories = $obj->searchCategory($keywords, $display_max, 0, 'normal');
//
// // ブランドサジェスト
// $brands = $obj->searchCategory($keywords, $display_max, 0, 'brand');
//
// // 説明サジェスト
// $descriptions = $obj->searchCategory($keywords, $display_max, 0, 'description');
//
// // view用に変換
// $this->view->searchtext = $searchtext;
// $this->view->display_max = $display_max;
// $this->view->keywords = $keywords;
// $this->view->categories = $categories;
// $this->view->brands = $brands;
// $this->view->descriptions = $descriptions;
//
$isMobile = $this->mobileDetector->isMobile();
$this->CommonService->SetPageLayout('item/detail', $isMobile, [], $isMobile ? 22 : 2);
//
return [
'searchtext' => $searchtext,
];
}
private function createGetParamater($getVar, $moji = "?", $expect = "", $and = "&", $equal = "=")
{
$form = "";
$array = explode(",", $expect);
while (!is_null($key = key($getVar))) {
if (!in_array($key, $array)) {
if ($form != "") {
//$form .= $and . $key . $equal . urlencode( LmHelper::display_form_text($getVar[$key]) ); 20110104 /の変換処理修正
$form .= $and . $key . $equal . str_replace("%2F", "%252F", urlencode(LmHelper::display_form_text($getVar[$key])));
urlencode($getVar[$key]);
} else {
//$form = $moji . $key . $equal . urlencode( LmHelper::display_form_text($getVar[$key]) ); 20110104 /の変換処理修正
$form = $moji . $key . $equal . str_replace("%2F", "%252F", urlencode(LmHelper::display_form_text($getVar[$key])));
}
}
next($getVar);
}
return $form;
}
public function LM_displayHosokuSetsumei2($data)
{
// 注文最低ロット
if ($data['goods_order_lot'] > 1) {
return "ご注文数は、" . $data['goods_order_lot'] . "ヶからです。";
}
}
/**
* @param int $goodsId
* @return string
*/
public static function getMasterCacheKey($goodsId)
{
//
$masterCacheKey = "item_index_id_{$goodsId}";
//
$masterCacheKey = str_replace('-', '_', $masterCacheKey);
//
return $masterCacheKey;
}
}