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.

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