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.

717 line
24KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Order;
  3. use App\Builder\Distribution\DistributionBuilder;
  4. use App\Entity\Distribution\Distribution;
  5. use App\Entity\User\User;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
  8. use Lc\CaracoleBundle\Model\Distribution\DistributionInterface;
  9. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  10. use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
  11. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  12. use Lc\CaracoleBundle\Model\Product\ProductInterface;
  13. use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
  14. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
  15. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
  16. use Lc\CaracoleBundle\Model\User\VisitorInterface;
  17. use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
  18. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  19. use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
  20. use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
  21. use Lc\CaracoleBundle\Repository\Section\SectionStore;
  22. use Lc\CaracoleBundle\Resolver\OpeningResolver;
  23. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  24. use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
  25. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  26. use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
  27. use Lc\SovBundle\Model\User\UserInterface;
  28. use Lc\CaracoleBundle\Repository\AbstractStore;
  29. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  30. use Lc\SovBundle\Solver\Setting\SettingSolver;
  31. use Lc\SovBundle\Translation\FlashBagTranslator;
  32. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  33. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  34. class OrderShopStore extends AbstractStore
  35. {
  36. use SectionStoreTrait;
  37. use MerchantStoreTrait;
  38. protected OrderShopRepositoryQuery $query;
  39. protected EntityManagerInterface $entityManager;
  40. protected PriceSolver $priceSolver;
  41. protected DocumentBuilder $documentBuilder;
  42. protected ReductionCreditStore $reductionCreditStore;
  43. protected ReductionCartSolver $reductionCartSolver;
  44. protected SectionStore $sectionStore;
  45. protected OrderProductStore $orderProductStore;
  46. protected MerchantStore $merchantStore;
  47. protected FlashBagTranslator $flashBagTranslator;
  48. protected OpeningResolver $openingResolver;
  49. protected ParameterBagInterface $parameterBag;
  50. protected UrlGeneratorInterface $router;
  51. protected OrderShopSolver $orderShopSolver;
  52. protected ReductionCartStore $reductionCartStore;
  53. protected DistributionBuilder $distributionBuilder;
  54. protected SettingSolver $settingSolver;
  55. public function __construct(
  56. OrderShopRepositoryQuery $query,
  57. EntityManagerInterface $entityManager,
  58. PriceSolver $priceSolver,
  59. DocumentBuilder $documentBuilder,
  60. ReductionCreditStore $reductionCreditStore,
  61. ReductionCartSolver $reductionCartSolver,
  62. SectionStore $sectionStore,
  63. OrderProductStore $orderProductStore,
  64. MerchantStore $merchantStore,
  65. FlashBagTranslator $flashBagTranslator,
  66. ParameterBagInterface $parameterBag,
  67. UrlGeneratorInterface $router,
  68. OrderShopSolver $orderShopSolver,
  69. ReductionCartStore $reductionCartStore,
  70. DistributionBuilder $distributionBuilder,
  71. SettingSolver $settingSolver
  72. )
  73. {
  74. $this->query = $query;
  75. $this->entityManager = $entityManager;
  76. $this->priceSolver = $priceSolver;
  77. $this->documentBuilder = $documentBuilder;
  78. $this->reductionCreditStore = $reductionCreditStore;
  79. $this->reductionCartSolver = $reductionCartSolver;
  80. $this->sectionStore = $sectionStore;
  81. $this->orderProductStore = $orderProductStore;
  82. $this->merchantStore = $merchantStore;
  83. $this->flashBagTranslator = $flashBagTranslator;
  84. $this->parameterBag = $parameterBag;
  85. $this->router = $router;
  86. $this->orderShopSolver = $orderShopSolver;
  87. $this->reductionCartStore = $reductionCartStore;
  88. $this->distributionBuilder = $distributionBuilder;
  89. $this->settingSolver = $settingSolver;
  90. }
  91. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  92. {
  93. //$query->orderBy('id', 'DESC');
  94. return $query;
  95. }
  96. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  97. {
  98. $this
  99. ->addFilterBySectionOptionnal($query)
  100. ->addFilterByMerchantViaSectionOptionnal($query);
  101. return $query;
  102. }
  103. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  104. {
  105. $query->joinOrderProducts(true);
  106. return $query;
  107. }
  108. // getOrderShopsOfWeek
  109. //getByCurrentCycle
  110. public function getByCurrentDistribution($params = [], $query = null)
  111. {
  112. return $this->getBy(
  113. array_merge(
  114. [
  115. 'distribution' => $this->distributionBuilder->guessCurrentDistributionOrder(
  116. $this->section
  117. ),
  118. 'isValid' => true,
  119. ],
  120. $params
  121. ),
  122. $query
  123. );
  124. }
  125. // getOrderShopsOfWeekByUser
  126. //getByCurrentCycleAndUser
  127. public function getByCurrentDistributionAndUser(UserInterface $user = null, array $params = [], $query = null)
  128. {
  129. return $this->getByCurrentDistribution(
  130. array_merge(
  131. [
  132. 'user' => $user,
  133. 'excludeComplementaryOrderShops' => true
  134. ],
  135. $params
  136. ),
  137. $query
  138. );
  139. }
  140. //public $countOrderShopsOfWeek = null;
  141. // public function countByCurrentCycle(bool $excludeComplementaryOrderShops = true, $query = null)
  142. //countByCurrentCycle
  143. public function countByCurrentDistribution(array $params, $query = null)
  144. {
  145. return $this->countBy(
  146. array_merge(
  147. [
  148. 'distribution' => $this->distributionBuilder->guessCurrentDistributionOrder(
  149. $this->section
  150. ),
  151. 'excludeComplementaryOrderShops' => isset($params['excludeComplementaryOrderShops']) ?? true,
  152. ],
  153. $params
  154. ),
  155. $query
  156. );
  157. // @TODO : optimisation à remettre en place
  158. /*if (is_null($this->countOrderShopsOfWeek)) {
  159. $this->countOrderShopsOfWeek = $this->getByCurrentCycle(
  160. $section,
  161. [
  162. 'count' => true,
  163. 'excludeComplementaryOrderShops' => $excludeComplementaryOrderShops
  164. ]
  165. );
  166. }
  167. return $this->countOrderShopsOfWeek;*/
  168. }
  169. // getNextWeekId
  170. public function getNextCycleId(Distribution $distribution, $query = null): int
  171. {
  172. $lastOrder = $this->getOneLastValidByDistribution($distribution, $query);
  173. if ($lastOrder) {
  174. return intval($lastOrder->getCycleId() + 1);
  175. } else {
  176. return 1;
  177. }
  178. }
  179. public function getNextIdValidOrder($query = null): int
  180. {
  181. $lastOrder = $this->getOneLastValid($query);
  182. if ($lastOrder) {
  183. return intval($lastOrder->getIdValidOrder() + 1);
  184. } else {
  185. return 1;
  186. }
  187. }
  188. public function countValidByUserAllMerchant($user, $query = null): int
  189. {
  190. $this->resetContext();
  191. return $this->countBy(
  192. [
  193. 'user' => $user,
  194. 'isValid' => true,
  195. 'excludeComplementaryOrderShops' => true
  196. ],
  197. $query
  198. );
  199. }
  200. public function countValidByUser(UserInterface $user = null, $query = null): int
  201. {
  202. return $this->countBy(
  203. [
  204. 'user' => $user,
  205. 'isValid' => true,
  206. 'excludeComplementaryOrderShops' => true
  207. ],
  208. $query
  209. );
  210. }
  211. //countValidByCurrentCycle
  212. public function countValidByCurrentDistribution($query = null): int
  213. {
  214. return $this->countBy(
  215. [
  216. 'distribution' => $this->distributionBuilder->guessCurrentDistributionOrder($this->section),
  217. 'isValid' => true,
  218. 'excludeComplementaryOrderShops' => true
  219. ],
  220. $query
  221. );
  222. }
  223. // countValidOrderWithReductionCredit
  224. public function countValidWithReductionCredit(
  225. ReductionCreditInterface $reductionCredit,
  226. UserInterface $user = null,
  227. $query = null
  228. ): int
  229. {
  230. //TODO vérifier que ne pas utiliser createDefaultQuery est pertinent
  231. $query = $this->createQuery($query);
  232. if ($user) {
  233. $query->filterByUser($user);
  234. }
  235. $query
  236. ->selectCount()
  237. ->filterByReductionCredit($reductionCredit)
  238. ->filterByStatus(OrderStatusModel::$statusAliasAsValid);
  239. return $query->count();
  240. }
  241. // countValidOrderWithReductionCart
  242. public function countValidWithReductionCart(
  243. ReductionCartInterface $reductionCart,
  244. $query = null
  245. ): int
  246. {
  247. $query = $this->createQuery($query);
  248. $query
  249. ->selectCount()
  250. ->filterByReductionCart($reductionCart)
  251. ->filterByStatus(OrderStatusModel::$statusAliasAsValid);
  252. return $query->count();
  253. }
  254. // countValidOrderWithReductionCartPerUser
  255. public function countValidWithReductionCartByUser(
  256. ReductionCartInterface $reductionCart,
  257. UserInterface $user,
  258. $query = null
  259. ): int
  260. {
  261. $query = $this->createDefaultQuery($query);
  262. $query
  263. ->selectCount()
  264. ->filterByUser($user)
  265. ->filterByReductionCart($reductionCart)
  266. ->filterByStatus(OrderStatusModel::$statusAliasAsValid);
  267. return $query->count();
  268. }
  269. // findCartCurrent
  270. public function getOneCartCurrent(
  271. UserInterface $user = null,
  272. VisitorInterface $visitor = null,
  273. $query = null
  274. ): ?OrderShopInterface
  275. {
  276. if (is_null($user) && is_null($visitor)) {
  277. return null;
  278. }
  279. $query = $this->createDefaultQuery($query);
  280. if (!is_null($user)) {
  281. $query->filterByUser($user);
  282. } else {
  283. if (!is_null($visitor)) {
  284. $query->filterByVisitor($visitor);
  285. }
  286. }
  287. $query
  288. ->selectOrderReductionCarts()
  289. ->filterByStatus(OrderStatusModel::$statusAliasAsCart);
  290. return $query->findOne();
  291. }
  292. // findLastOrderValidOfWeek
  293. //getOneLastValidByCycle
  294. public function getOneLastValidByDistribution(
  295. DistributionInterface $distribution,
  296. $query = null
  297. ): ?OrderShopInterface
  298. {
  299. $query = $this->createDefaultQuery($query);
  300. $query
  301. ->filterByDistribution($distribution)
  302. ->filterByStatus(OrderStatusModel::$statusAliasAsValid)
  303. ->filterIsNotComplementaryOrderShop()
  304. ->orderBy('.cycleId', 'DESC');
  305. return $query->findOne();
  306. }
  307. public function getOneValidByDistributionAndUser(
  308. DistributionInterface $distribution,
  309. UserInterface $user,
  310. $query = null
  311. ): ?OrderShopInterface
  312. {
  313. $query = $this->createDefaultQuery($query);
  314. $query
  315. ->filterByDistribution($distribution)
  316. ->filterByUser($user)
  317. ->filterByStatus(OrderStatusModel::$statusAliasAsValid)
  318. ->filterIsNotComplementaryOrderShop()
  319. ->orderBy('.cycleId', 'DESC');
  320. return $query->findOne();
  321. }
  322. //findLastOrderValid
  323. public function getOneLastValid($query = null): ?OrderShopInterface
  324. {
  325. $query = $this->createDefaultQuery($query);
  326. $query
  327. ->filterByStatus(OrderStatusModel::$statusAliasAsValid)
  328. ->filterIsNotComplementaryOrderShop()
  329. ->orderBy('.idValidOrder', 'DESC');
  330. return $query->findOne();
  331. }
  332. public function countBy(array $params = [], $query = null)
  333. {
  334. $query = $this->createDefaultQuery($query);
  335. $query->selectCount();
  336. $this->applyGetByFilters($params, $query);
  337. return $query->count();
  338. }
  339. public function getBy(array $params = [], $query = null): array
  340. {
  341. $query = $this->createDefaultQuery($query);
  342. $this->applyGetByFilters($params, $query);
  343. $orderShops = $query->find();
  344. if (isset($params['mergeComplementaryOrderShops']) && $params['mergeComplementaryOrderShops'] == true) {
  345. $mergeComplementaryOrderShopsSameSection = isset($params['mergeComplementaryOrderShopsSameSection'])
  346. ? $params['mergeComplementaryOrderShopsSameSection'] : false;
  347. foreach ($orderShops as $orderShop) {
  348. $this->orderShopSolver->mergeComplentaryOrderShops($orderShop, true, $mergeComplementaryOrderShopsSameSection);
  349. }
  350. }
  351. return $orderShops;
  352. }
  353. protected function applyGetByFilters(array $params, $query)
  354. {
  355. if (isset($params['isDeliveryHome']) && $params['isDeliveryHome']) {
  356. $query->filterIsDeliveryHome();
  357. }
  358. if (isset($params['isDeliveryPointSale']) && $params['isDeliveryPointSale']) {
  359. $query->filterIsDeliveryPointSale();
  360. }
  361. if (isset($params['isMerchantOnline'])) {
  362. $query->filterIsMerchantOnline();
  363. }
  364. if (isset($params['select'])) {
  365. $query->selectParam($params['select']);
  366. }
  367. if (isset($params['dateStart']) || isset($params['dateEnd'])) {
  368. $params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate';
  369. }
  370. if (isset($params['dateStart'])) {
  371. $query->filterByDateStart($params['dateField'], $params['dateStart']);
  372. }
  373. if (isset($params['dateEnd'])) {
  374. $query->filterByDateEnd($params['dateField'], $params['dateEnd']);
  375. }
  376. if (isset($params['distribution'])) {
  377. $query->filterByDistribution($params['distribution']);
  378. }
  379. if (isset($params['distributions'])) {
  380. $query->filterByDistributions($params['distributions']);
  381. }
  382. if (isset($params['isCart'])) {
  383. $query->filterByStatus(OrderStatusModel::$statusAliasAsCart);
  384. }
  385. if (isset($params['isValid'])) {
  386. $query->filterByStatus(OrderStatusModel::$statusAliasAsValid);
  387. }
  388. if (isset($params['isWaitingDelivery'])) {
  389. $query->filterByStatus(OrderStatusModel::$statusAliasWaitingDelivery);
  390. }
  391. if (isset($params['orderStatus'])) {
  392. $query->filterByStatus([$params['orderStatus']]);
  393. }
  394. if (isset($params['user'])) {
  395. $query->filterByUser($params['user']);
  396. }
  397. if (isset($params['address'])) {
  398. $query->filterByAddress($params['address']);
  399. }
  400. if (isset($params['minimumTomorrowDelivery'])) {
  401. $query->filterMinimumTomorrowDelivery();
  402. }
  403. if (isset($params['mergeComplementaryOrderShops']) && $params['mergeComplementaryOrderShops']) {
  404. $query
  405. ->joinComplementaryOrderShops();
  406. }
  407. if (isset($params['isComplementaryOrderShop']) && $params['isComplementaryOrderShop']) {
  408. $query->filterIsComplementaryOrderShop();
  409. if (isset($params['sectionMainOrderShop']) && $params['sectionMainOrderShop']) {
  410. $query->filterSectionMainOrderShop($params['sectionMainOrderShop']);
  411. }
  412. }
  413. if ((isset($params['excludeComplementaryOrderShops']) && $params['excludeComplementaryOrderShops'])
  414. || (isset($params['mergeComplementaryOrderShops']) && $params['mergeComplementaryOrderShops'])) {
  415. $query->filterIsNullMainOrderShop();
  416. }
  417. if (isset($params['joinProductFamily'])) {
  418. $query->joinProductFamily(true);
  419. }
  420. if (isset($params['orderBy'])) {
  421. $sort = isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC';
  422. $query->orderBy($params['orderBy'], $sort);
  423. } else {
  424. $query->orderBy('.id', 'DESC');
  425. }
  426. if (isset($params['groupBy'])) {
  427. $query->groupBy($params['groupBy']);
  428. }
  429. return $query;
  430. }
  431. public function isReductionGiftUsed(ReductionCreditInterface $reductionGift, $query = null)
  432. {
  433. if ($this->countValidWithReductionCredit($reductionGift, null, $query)) {
  434. return true;
  435. } else {
  436. return false;
  437. }
  438. }
  439. public function isReductionCreditUsed(
  440. ReductionCreditInterface $reductionCredit,
  441. UserInterface $user = null,
  442. $query = null
  443. )
  444. {
  445. if ($this->countValidWithReductionCredit($reductionCredit, $user, $query)) {
  446. return true;
  447. } else {
  448. return false;
  449. }
  450. }
  451. public function getReductionCreditsAvailableByUser(UserInterface $user): array
  452. {
  453. $reductionCredits = $this->reductionCreditStore
  454. ->setMerchant($this->merchant)
  455. ->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user);
  456. $reductionCreditsArray = [];
  457. foreach ($reductionCredits as $reductionCredit) {
  458. if (!$this->countValidWithReductionCredit($reductionCredit, $user)) {
  459. $reductionCreditsArray[] = $reductionCredit;
  460. }
  461. }
  462. return $reductionCreditsArray;
  463. }
  464. public function getReductionGiftsAvailableByUser(UserInterface $user): array
  465. {
  466. $reductionGifts = $this->reductionCreditStore
  467. ->setMerchant($this->merchant)
  468. ->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user);
  469. $reductionGiftsArray = [];
  470. foreach ($reductionGifts as $reductionGift) {
  471. if (!$this->countValidWithReductionCredit($reductionGift, $user)) {
  472. $reductionGiftsArray[] = $reductionGift;
  473. }
  474. }
  475. return $reductionGiftsArray;
  476. }
  477. // getReductionCartRemainingQuantity
  478. public function getReductionCartRemainingQuantity(ReductionCartInterface $reductionCart): float
  479. {
  480. return $reductionCart->getAvailableQuantity() - $this->countValidWithReductionCart(
  481. $reductionCart
  482. );
  483. }
  484. // getReductionCartUsedQuantityPerUser
  485. public function getReductionCartUsedQuantityByUser(
  486. ReductionCartInterface $reductionCart,
  487. UserInterface $user
  488. ): float
  489. {
  490. return $this->countValidWithReductionCartByUser($reductionCart, $user);
  491. }
  492. // getReductionCartUsedQuantity
  493. public function getReductionCartUsedQuantity(ReductionCartInterface $reductionCart): float
  494. {
  495. return $this->countValidWithReductionCart($reductionCart);
  496. }
  497. // getReductionCartRemainingQuantityPerUser
  498. public function getReductionCartRemainingQuantityByUser(
  499. ReductionCartInterface $reductionCart,
  500. UserInterface $user
  501. ): float
  502. {
  503. if ($reductionCart->getAvailableQuantityPerUser()) {
  504. return $reductionCart->getAvailableQuantityPerUser() - $this->countValidWithReductionCartByUser(
  505. $reductionCart,
  506. $user
  507. );
  508. }
  509. return false;
  510. }
  511. // findAllAvailableForUser / getReductionCartsAvailableByUser
  512. public function getReductionCartAvailableByUser(UserInterface $user, string $type = null, $query = null)
  513. {
  514. $reductionCarts = $this->reductionCartStore
  515. ->setMerchant($this->merchant)
  516. ->getOnline();
  517. $reductionCartsArray = [];
  518. foreach ($reductionCarts as $reductionCart) {
  519. if ($this->reductionCartSolver->matchWithUser($reductionCart, $user)
  520. && $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user)
  521. && $this->getReductionCartRemainingQuantityByUser($reductionCart, $user)
  522. && ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)
  523. && (!$this->merchant || $reductionCart->getMerchant() == $this->merchant)) {
  524. if(!$type || $reductionCart->getType() == $type) {
  525. $reductionCartsArray[] = $reductionCart;
  526. }
  527. }
  528. }
  529. return $reductionCartsArray;
  530. }
  531. //countValidOrderProductsOfCyclesByProducts
  532. public function countValidOrderProductsOfDistributionsByProducts(
  533. array $distributions,
  534. array $products,
  535. ProductFamilyInterface $productFamily,
  536. $query = null
  537. ): array
  538. {
  539. $query = $this->createDefaultQuery($query);
  540. $query
  541. ->filterByAlias(OrderStatusModel::$statusAliasAsValid)
  542. ->filterByDistributions($distributions)
  543. ->filterByProducts($products)
  544. ->selectSum()
  545. ->groupBy('distribution.cycleNumber, product.id');
  546. //TODO vérifier ou est utilisé cette fonction ???
  547. return $query->find();
  548. }
  549. //countValidOrderProductsOfCycleByProduct
  550. public function countValidOrderProductsOfDistributionByProduct(
  551. DistributionInterface $distribution,
  552. ProductInterface $product,
  553. $query = null
  554. ): float
  555. {
  556. //TODO attention à vérifier
  557. $query = $this->createQuery($query);
  558. $query
  559. ->filterByAlias(OrderStatusModel::$statusAliasAsValid)
  560. ->filterByDistribution($distribution)
  561. ->filterByProduct($product)
  562. ->selectSumQuantityOrder()
  563. ->joinDistribution()
  564. ->groupBy('distribution.cycleNumber, product.id');
  565. $result = $query->findOne();
  566. if ($result) {
  567. return $result['quantity'];
  568. }
  569. return 0;
  570. }
  571. public function isReductionCreditAllowAddToOrder(
  572. OrderShopInterface $orderShop,
  573. ReductionCreditInterface $reductionCredit
  574. )
  575. {
  576. $user = $orderShop->getUser();
  577. // appartient à l'utilisateur
  578. if (!$reductionCredit->getUsers()->contains($user)) {
  579. // @TODO : déplacer la gestion du flash message
  580. $this->flashBagTranslator->add('error', 'userNotAllow', 'ReductionCredit');
  581. return false;
  582. }
  583. // n'a pas été utilisé
  584. if ($reductionCredit->getType() == ReductionCreditModel::TYPE_CREDIT) {
  585. if ($this->countValidWithReductionCredit($reductionCredit, $user) > 0) {
  586. // @TODO : déplacer la gestion du flash message
  587. $this->flashBagTranslator->add('error', 'alreadyUse', 'ReductionCredit');
  588. return false;
  589. }
  590. } else {
  591. if ($this->countValidWithReductionCredit($reductionCredit) > 0) {
  592. // @TODO : déplacer la gestion du flash message
  593. $this->flashBagTranslator->add('error', 'alreadyUse', 'ReductionCredit');
  594. return false;
  595. }
  596. }
  597. return true;
  598. }
  599. public function getCartAlone($query = null)
  600. {
  601. $query = $this->createQuery($query);
  602. $query->filterByAlias(OrderStatusModel::$statusAliasAsCart);
  603. $query->filterByUserIsNull();
  604. $query->filterByVisitorIsNull();
  605. return $query->limit(10000)->find();
  606. }
  607. }