1 | <?php |
||
23 | class ProductRepository extends BaseProductRepository implements ProductRepositoryInterface |
||
24 | { |
||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | public function createListQueryBuilder($locale, $taxonId = null) |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function createShopListQueryBuilder(ChannelInterface $channel, TaxonInterface $taxon, $locale, array $sorting) |
||
51 | { |
||
52 | $queryBuilder = $this->createQueryBuilder('o') |
||
53 | ->addSelect('translation') |
||
54 | ->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale') |
||
55 | ->innerJoin('o.productTaxons', 'productTaxon') |
||
56 | ->andWhere('productTaxon.taxon = :taxon') |
||
57 | ->andWhere(':channel MEMBER OF o.channels') |
||
58 | ->andWhere('o.enabled = true') |
||
59 | ->addGroupBy('o.id') |
||
60 | ->setParameter('locale', $locale) |
||
61 | ->setParameter('taxon', $taxon) |
||
62 | ->setParameter('channel', $channel) |
||
63 | ; |
||
64 | |||
65 | // Grid hack, we do not need to join these if we don't sort by price |
||
66 | if (isset($sorting['price'])) { |
||
67 | $queryBuilder |
||
68 | ->innerJoin('o.variants', 'variant') |
||
69 | ->innerJoin('variant.channelPricings', 'channelPricing') |
||
70 | ->andWhere('channelPricing.channel = :channel') |
||
71 | ; |
||
72 | } |
||
73 | |||
74 | return $queryBuilder; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function findLatestByChannel(ChannelInterface $channel, $count) |
||
81 | { |
||
82 | return $this->createQueryBuilder('o') |
||
83 | ->andWhere(':channel MEMBER OF o.channels') |
||
84 | ->andWhere('o.enabled = true') |
||
85 | ->addOrderBy('o.createdAt', 'DESC') |
||
86 | ->setParameter('channel', $channel) |
||
87 | ->setMaxResults($count) |
||
88 | ->getQuery() |
||
89 | ->getResult() |
||
90 | ; |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function findOneBySlugAndChannel($slug, ChannelInterface $channel) |
||
97 | { |
||
98 | return $this->createQueryBuilder('o') |
||
99 | ->innerJoin('o.translations', 'translation') |
||
100 | ->andWhere('translation.slug = :slug') |
||
101 | ->andWhere(':channel MEMBER OF o.channels') |
||
102 | ->andWhere('o.enabled = true') |
||
103 | ->setParameter('slug', $slug) |
||
104 | ->setParameter('channel', $channel) |
||
105 | ->getQuery() |
||
106 | ->getOneOrNullResult() |
||
107 | ; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function findOneBySlug($slug) |
||
124 | } |
||
125 |