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.

OrderProductStore.php 1.3KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Order;
  3. use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
  4. use Lc\CaracoleBundle\Model\Product\ProductInterface;
  5. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  6. use Lc\SovBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class OrderProductStore extends AbstractStore
  9. {
  10. use SectionStoreTrait;
  11. protected OrderProductRepositoryQuery $query;
  12. public function __construct(OrderProductRepositoryQuery $query)
  13. {
  14. $this->query = $query;
  15. }
  16. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  17. {
  18. $query->orderBy('id');
  19. return $query;
  20. }
  21. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  22. {
  23. $query->filterBySection($this->section);
  24. return $query;
  25. }
  26. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  27. {
  28. return $query;
  29. }
  30. //findOrderProductsInCartsByProduct
  31. public function getInCartsByProduct(ProductInterface $product, $query = null): array
  32. {
  33. $query = $this->createDefaultQuery($query);
  34. $query->filterByProduct($product);
  35. $query->filterByOrderStatus(OrderStatusModel::$statusAliasAsValid);
  36. return $query->find();
  37. }
  38. }