|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Product;
-
- use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
- use Lc\CaracoleBundle\Repository\SectionStoreTrait;
- use Lc\CaracoleBundle\Solver\Price\PriceSolver;
- use Lc\SovBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class ProductFamilyStore extends AbstractStore
- {
- use SectionStoreTrait;
-
- protected ProductFamilyRepositoryQuery $query;
- protected PriceSolver $priceSolver;
-
- public function __construct(ProductFamilyRepositoryQuery $query, PriceSolver $priceSolver)
- {
- $this->query = $query;
- $this->priceSolver = $priceSolver;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('position');
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
-
- {
- $query->filterBySection($this->section);
- return $query;
- }
-
- public function relationsDefault($query): RepositoryQueryInterface
- {
- $query->joinProductCategories();
- $query->joinProducts();
- return $query;
- }
-
- //getProductFamiliesByCategory
- public function getByCategory(ProductCategoryInterface $productCategory, $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterIsOnline()
- ->filterByProductCategory($productCategory);
-
- return $query->find();
- }
- //getProductFamiliesNovelties
- public function getByNovelties($query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByPropertyNoveltyExpirationDate()
- ->filterIsOnline();
-
- return $query->find();
- }
-
- //getProductFamiliesOrganics
- public function getOrganics($query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterPropertyOrganicLabel()
- ->filterIsOnline();
-
- return $query->find();
- }
- //findByTerms
- public function getByTerms($terms, $maxResults = false, $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query->filterIsOnline();
- $query->groupBy('id');
-
- if($maxResults) {
- $query->limit($maxResults);
- }
-
- return $query->find();
- }
-
-
-
- }
|