6 declare(strict_types=1);
27 private $isSingleSourceMode;
32 private $isSourceItemManagementAllowedForProductType;
37 private $sourceRepository;
42 private $getSourceItemsBySku;
56 $this->isSingleSourceMode = $isSingleSourceMode;
57 $this->isSourceItemManagementAllowedForProductType = $isSourceItemManagementAllowedForProductType;
67 if (0 ===
$data[
'totalRecords'] ||
true === $this->isSingleSourceMode->execute()) {
72 $item[
'quantity_per_source'] = $this->isSourceItemManagementAllowedForProductType->execute(
74 ) ===
true ? $this->getSourceItemsData(
$item[
'sku']) : [];
86 private function getSourceItemsData(
string $sku): array
88 $sourceItems = $this->getSourceItemsBySku->execute($sku);
90 $sourceItemsData = [];
95 $sourceItemsData[] = [
96 'source_name' =>
$source->getName(),
100 return $sourceItemsData;
108 if (
true === $this->isSingleSourceMode->execute()) {
112 $meta = array_replace_recursive($meta, [
113 'product_columns' => [
115 'quantity_per_source' => $this->getQuantityPerSourceMeta(),
128 private function getQuantityPerSourceMeta(): array
137 'label' =>
__(
'Quantity per Source'),
140 'component' =>
'Magento_InventoryCatalogAdminUi/js/product/grid/cell/quantity-per-source',
__construct(IsSingleSourceModeInterface $isSingleSourceMode, IsSourceItemManagementAllowedForProductTypeInterface $isSourceItemManagementAllowedForProductType, SourceRepositoryInterface $sourceRepository, GetSourceItemsBySkuInterface $getSourceItemsBySku)