for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?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 Eccube\Service\Product;
use Eccube\Doctrine\Query\WhereClause;
use Eccube\Entity\Master\ProductStatus;
use Eccube\Entity\Product;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class StatusVisibility extends ProductVisibility
{
/**
* @var SessionInterface
private $session;
public function __construct(SessionInterface $session)
$this->session = $session;
}
public function checkVisibility(Product $Product)
$is_admin = $this->session->has('_security_admin');
// 管理ユーザの場合はステータスやオプションにかかわらず閲覧可能.
if (!$is_admin) {
// 在庫なし商品の非表示オプションが有効な場合.
// if ($this->BaseInfo->isOptionNostockHidden()) {
// if (!$Product->getStockFind()) {
// return false;
// }
// 公開ステータスでない商品は表示しない.
if ($Product->getStatus()->getId() !== ProductStatus::DISPLAY_SHOW) {
return false;
return true;
protected function createStatements($params, $queryKey)
return [
WhereClause::eq('p.Status', ':ProductStatus', ProductStatus::DISPLAY_SHOW)
];