sourceRepository = $sourceRepository; $this->bulkSessionProductsStorage = $bulkSessionProductsStorage; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->getSourceCodesBySkus = $getSourceCodesBySkus; } /** * Get a list of available sources * @return SourceInterface[] */ public function getSources(): array { return $this->sourceRepository->getList()->getItems(); } /** * Get a list of sources assigned to the products selection * @return SourceInterface[] */ public function getAssignedSources(): array { $skus = $this->bulkSessionProductsStorage->getProductsSkus(); $sourceCodes = $this->getSourceCodesBySkus->execute($skus); $searchCriteria = $this->searchCriteriaBuilder ->addFilter( SourceItemInterface::SOURCE_CODE, $sourceCodes, 'in' ) ->create(); return $this->sourceRepository->getList($searchCriteria)->getItems(); } /** * @return int */ public function getProductsCount(): int { return count($this->bulkSessionProductsStorage->getProductsSkus()); } }