You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProductStore.php 1.2KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Product;
  3. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  4. use Lc\SovBundle\Repository\AbstractStore;
  5. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  6. class ProductStore extends AbstractStore
  7. {
  8. use SectionStoreTrait;
  9. protected ProductRepositoryQuery $query;
  10. public function __construct(ProductRepositoryQuery $query)
  11. {
  12. $this->query = $query;
  13. }
  14. public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface
  15. {
  16. return $query;
  17. }
  18. public function filtersDefault($query):RepositoryQueryInterface
  19. {
  20. $query->filterIsOnlineAndOffline();
  21. $query->filterBySection($this->section);
  22. return $query;
  23. }
  24. public function relationsDefault($query):RepositoryQueryInterface
  25. {
  26. return $query->joinProductFamily();
  27. }
  28. //findProductByAvailabilitiesNegative
  29. public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array
  30. {
  31. $query = $this->createQuery($query);
  32. $query->joinProductFamily();
  33. $query->filterIsOnline();
  34. $query->filterBehaviorCountStock();
  35. $query->groupBy('pf.id');
  36. return $query->find();
  37. }
  38. }