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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Product;
  3. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  4. use Lc\CaracoleBundle\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. $this->addFilterBySectionOptionnal($query);
  21. $query->filterIsOnlineAndOffline();
  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. }