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