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.

50 lines
1.4KB

  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. if($this->section) {
  24. $query->filterBySection($this->section);
  25. }
  26. return $query;
  27. }
  28. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  29. {
  30. return $query;
  31. }
  32. //findOrderProductsInCartsByProduct
  33. public function getInCartsByProduct(ProductInterface $product, $query = null): array
  34. {
  35. $query = $this->createDefaultQuery($query);
  36. $query->filterByProduct($product);
  37. $query->filterByOrderStatus(OrderStatusModel::$statusAliasAsValid);
  38. return $query->find();
  39. }
  40. }