Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)
 {
     $quoteCollection = $this->quoteCollectionFactory->create();
     $this->extensionAttributesJoinProcessor->process($quoteCollection);
     $searchData = $this->searchResultsDataFactory->create();
     $searchData->setSearchCriteria($searchCriteria);
     $searchData->setItems($quoteCollection->getItems());
     return $searchData;
 }
 /**
  * Clean expired quotes (cron process)
  *
  * @return void
  */
 public function execute()
 {
     $lifetimes = $this->storesConfig->getStoresConfigByPath('checkout/cart/delete_quote_after');
     foreach ($lifetimes as $storeId => $lifetime) {
         $lifetime *= self::LIFETIME;
         /** @var $quotes \Magento\Quote\Model\Resource\Quote\Collection */
         $quotes = $this->quoteCollectionFactory->create();
         $quotes->addFieldToFilter('store_id', $storeId);
         $quotes->addFieldToFilter('updated_at', ['to' => date("Y-m-d", time() - $lifetime)]);
         $quotes->addFieldToFilter('is_active', 0);
         foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) {
             $quotes->addFieldToFilter($field, $condition);
         }
         $quotes->walk('delete');
     }
 }