17 use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory;
62 private $extensionAttributesJoinProcessor;
77 private $collectionProcessor;
82 private $quoteCollectionFactory;
108 $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
118 public function get(
$cartId, array $sharedStoreIds = [])
120 if (!isset($this->quotesById[
$cartId])) {
121 $quote = $this->loadQuote(
'loadByIdWithoutStore',
'cartId',
$cartId, $sharedStoreIds);
122 $this->getLoadHandler()->load(
$quote);
125 return $this->quotesById[
$cartId];
133 if (!isset($this->quotesByCustomerId[
$customerId])) {
134 $quote = $this->loadQuote(
'loadByCustomer',
'customerId',
$customerId, $sharedStoreIds);
135 $this->getLoadHandler()->load(
$quote);
148 if (!
$quote->getIsActive()) {
160 if (!
$quote->getIsActive()) {
172 $currentQuote = $this->
get($quote->getId(), [
$quote->getStoreId()]);
174 foreach ($currentQuote->getData() as $key =>
$value) {
175 if (!
$quote->hasData($key)) {
181 $this->getSaveHandler()->save(
$quote);
182 unset($this->quotesById[
$quote->getId()]);
183 unset($this->quotesByCustomerId[
$quote->getCustomerId()]);
208 protected function loadQuote($loadMethod, $loadField, $identifier, array $sharedStoreIds = [])
211 $quote = $this->quoteFactory->create();
212 if ($sharedStoreIds) {
213 $quote->setSharedStoreIds($sharedStoreIds);
215 $quote->setStoreId($this->storeManager->getStore()->getId())->$loadMethod($identifier);
227 $this->quoteCollection = $this->quoteCollectionFactory->create();
229 $searchData = $this->searchResultsDataFactory->create();
232 $this->collectionProcessor->process(
$searchCriteria, $this->quoteCollection);
233 $this->extensionAttributesJoinProcessor->process($this->quoteCollection);
234 foreach ($this->quoteCollection->getItems() as
$quote) {
236 $this->getLoadHandler()->load(
$quote);
238 $searchData->setItems($this->quoteCollection->getItems());
239 $searchData->setTotalCount($this->quoteCollection->getSize());
256 foreach ($filterGroup->
getFilters() as $filter) {
257 $fields[] = $filter->getField();
258 $condition = $filter->getConditionType() ? $filter->getConditionType() :
'eq';
259 $conditions[] = [$condition => $filter->getValue()];
271 private function getSaveHandler()
273 if (!$this->saveHandler) {
276 return $this->saveHandler;
283 private function getLoadHandler()
285 if (!$this->loadHandler) {
288 return $this->loadHandler;
getForCustomer($customerId, array $sharedStoreIds=[])
$searchResultsDataFactory
save(\Magento\Quote\Api\Data\CartInterface $quote)
getActiveForCustomer($customerId, array $sharedStoreIds=[])
static singleField($fieldName, $fieldValue)
__construct(QuoteFactory $quoteFactory, StoreManagerInterface $storeManager, \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection, \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory, JoinProcessorInterface $extensionAttributesJoinProcessor, CollectionProcessorInterface $collectionProcessor=null, \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteCollectionFactory=null)
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
addFilterGroupToCollection(FilterGroup $filterGroup, QuoteCollection $collection)
getActive($cartId, array $sharedStoreIds=[])