Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cart.php
Go to the documentation of this file.
1 <?php
7 
14 {
21  protected function _construct()
22  {
23  $this->_init('quote', 'entity_id');
24  }
25 
32  public function fetchItemsSummary($quoteId)
33  {
34  $connection = $this->getConnection();
35  $select = $connection->select()->from(
36  ['q' => $this->getTable('quote')],
37  ['items_qty', 'items_count']
38  )->where(
39  'q.entity_id = :quote_id'
40  );
41 
42  $result = $connection->fetchRow($select, [':quote_id' => $quoteId]);
43  return $result ? $result : ['items_qty' => 0, 'items_count' => 0];
44  }
45 
52  public function fetchItems($quoteId)
53  {
54  $connection = $this->getConnection();
55  $select = $connection->select()->from(
56  ['qi' => $this->getTable('quote_item')],
57  ['id' => 'item_id', 'product_id', 'super_product_id', 'qty', 'created_at']
58  )->where(
59  'qi.quote_id = :quote_id'
60  );
61 
62  return $connection->fetchAll($select, [':quote_id' => $quoteId]);
63  }
64 
73  {
74  $connection = $this->getConnection();
75  $exclusionSelect = $connection->select()->from(
76  $this->getTable('quote_item'),
77  ['product_id']
78  )->where(
79  'quote_id = ?',
80  $quoteId
81  );
82  $condition = $connection->prepareSqlCondition('e.entity_id', ['nin' => $exclusionSelect]);
83  $collection->getSelect()->where($condition);
84  return $this;
85  }
86 }
addExcludeProductFilter($collection, $quoteId)
Definition: Cart.php:72
$connection
Definition: bulk.php:13