isJoinProductFamilySectionProperties) { $this->isJoinProductFamilySectionProperties = true; $this->leftJoin('.productFamilySectionProperties', 'pfsp'); if ($addSelect) { $this->addSelect('pfsp'); } } return $this; } public function joinQualityLabels(bool $addSelect = true): self { if (!$this->isJoinQualityLabels) { $this->isJoinQualityLabels = true; $this->leftJoin('.qualityLabels', 'pfql'); if ($addSelect) { $this->addSelect('pfql'); } } return $this; } public function filterBySection(SectionInterface $section,bool $addSelectProductFamilySectionProperties = true) { $this->joinProductFamilySectionProperties($addSelectProductFamilySectionProperties); $this->andWhereSection('pfsp', $section); $this->andWhere('pfsp.status = 1'); } public function selectCount(): self { return $this->select('count(pf.id)'); } public function selectProductCategories(): self { $this->joinProductCategories(); return $this->addSelect('pCategories'); } public function filterLikeBehaviorStockCycle(string $behaviorStockCycle): self { return $this ->andWhere('.behaviorStockCycle LIKE :behaviorStockCycle') ->setParameter('behaviorStockCycle', $behaviorStockCycle); } public function filterByProductCategory(ProductCategoryInterface $category): self { $this->joinProductCategories(); return $this ->andWhere(':category MEMBER OF .productCategories') ->setParameter('category', $category->getId()); } public function filterByPropertyNoveltyExpirationDate($dateTime = null): self { if (is_null($dateTime)) { $dateTime = new \DateTime(); } return $this->andWhere(':now <= .propertyNoveltyExpirationDate') ->setParameter('now', $dateTime); } public function filterIsOrganicLabel(): self { return $this->andWhere('.propertyOrganicLabel IS NOT NULL'); } public function filterIsNovelty() { return $this->andWhere(':now <= .propertyNoveltyExpirationDate') ->setParameter('now', new \DateTime()) ; } public function filterByTerms($terms): self { $this->andWhere('.title LIKE :terms OR cat.title LIKE :terms'); $this->setParameter(':terms', '%'.$terms.'%') ; return $this; } public function filterBySupplier($supplier): self { return $this->andWhereEqual('supplier', $supplier); } public function joinProductCategories(bool $addSelect = false): self { if (!$this->isJoinProductCategories) { $this->isJoinProductCategories = true; return $this ->leftJoin('.productCategories', 'cat') ->addSelect('cat') ; } return $this; } public function selectProducts(): self { $this->joinProducts(); return $this->addSelect('products'); } public function joinProducts(): self { if (!$this->isJoinProducts) { $this->isJoinProducts = true; return $this ->innerJoin('.products', 'pfp') ->addSelect('pfp') ; } return $this; } public function orderByPosition(): self { $this->orderBy('e.position', 'ASC'); return $this; } }