app/Customize/Repository/ProductRepositoryCustomize.php line 48

Open in your IDE?
  1. <?php
  2. namespace Customize\Repository;
  3. use Eccube\Entity\Product;
  4. use Eccube\Repository\ProductRepository;
  5. use Doctrine\Persistence\ManagerRegistry as RegistryInterface;
  6. use Eccube\Common\EccubeConfig;
  7. use Eccube\Doctrine\Query\Queries;
  8. use Eccube\Repository\Master\ProductStatusRepository;
  9. class ProductRepositoryCustomize extends ProductRepository{
  10.     /** @var ProductSalesRepository */
  11.     protected $productSalesRepository;
  12.     /** @var ProductStatusRepository */
  13.     protected $productStatusRepository// 追加
  14.     /**
  15.      * ProductRepository constructor.
  16.      *
  17.      * @param RegistryInterface $registry
  18.      * @param Queries $queries
  19.      * @param EccubeConfig $eccubeConfig
  20.      * @param ProductStatusRepository $productStatusRepository
  21.      */
  22.     public function __construct(
  23.         RegistryInterface $registry,
  24.         Queries $queries,
  25.         EccubeConfig $eccubeConfig,
  26.         ProductSalesRepository $productSalesRepository,
  27.         ProductStatusRepository $productStatusRepository
  28.     ) {
  29.         parent::__construct($registry$queries,$eccubeConfig);
  30.         $this->productSalesRepository $productSalesRepository;
  31.         $this->productStatusRepository $productStatusRepository;
  32.     }
  33.     /**
  34.      * 指定カラムの並び順で全データを取得
  35.      *
  36.      * @param string $column
  37.      * @param string $type
  38.      * @return void
  39.      */
  40.     public function getOrderBy(string $column 'id',string $type 'DESC'){
  41.         $status $this->productStatusRepository->findOneBy(['id' => 1]);
  42.         $qb $this->createQueryBuilder('p');
  43.         $qb->innerJoin('p.ProductClasses''pc');
  44.         $qb->andWhere('p.Status = :Status')->setParameter('Status',$status);
  45.         $qb->andWhere('pc.visible = :visible')->setParameter('visible'1);
  46.         $qb->orderBy('p.' $column,$type);
  47.         return $qb->getQuery()->getResult();
  48.     }
  49.     /**
  50.      * 指定の販売IDの商品を取得する
  51.      *
  52.      * @param integer $id
  53.      * @param string $column
  54.      * @param string $type
  55.      * @return void
  56.      */
  57.     public function getProductSales(int $id,string $column 'id',string $type 'DESC'){
  58.         $productSales $this->productSalesRepository->find($id);
  59.         $qb $this->createQueryBuilder('p');
  60.         $qb->where('p.ProductSales = :sales')->setParameter('sales',$productSales);
  61.         $qb->orderBy('p.' $column,$type);
  62.         return $qb->getQuery()->getResult();
  63.     }
  64. }