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(); } public function getBestReductionCatalog( ProductFamilyInterface $productFamily, ReductionCatalogInterface $reductionCatalog1, ReductionCatalogInterface $reductionCatalog2 ) { $price1 = $this->priceSolver->applyReductionCatalog( $productFamily, $this->priceSolver->getPrice($productFamily), $this->priceSolver->getPriceWithTax($productFamily), 1, $reductionCatalog1 ); $price2 = $this->priceSolver->applyReductionCatalog( $productFamily, $this->priceSolver->getPrice($productFamily), $this->priceSolver->getPriceWithTax($productFamily), 1, $reductionCatalog2 ); if ($price1 > $price2) { return $reductionCatalog2; } else { return $reductionCatalog1; } } }