Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
GetSourceItemsCollection.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 use Magento\Inventory\Model\ResourceModel\SourceItem\CollectionFactory;
13 
18 {
22  private $collectionFactory;
23 
27  private $selectBuilder;
28 
33  public function __construct(
34  CollectionFactory $collectionFactory,
35  SelectBuilder $selectBuilder
36  ) {
37  $this->collectionFactory = $collectionFactory;
38  $this->selectBuilder = $selectBuilder;
39  }
40 
44  public function execute()
45  {
46  $collection = $this->collectionFactory->create();
47  $collection->removeAllFieldsFromSelect();
49  $collection->addFieldToSelect(SourceItemInterface::QUANTITY, 'qty');
50 
51  $this->selectBuilder->build($collection->getSelect());
52 
53  return $collection;
54  }
55 }