Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-inventory-catalog-admin-ui
Model
GetSourceItemsDataBySku.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalogAdminUi\Model
;
9
10
use
Magento\InventoryApi\Api\Data\SourceItemInterface
;
11
use
Magento\InventoryApi\Api\SourceItemRepositoryInterface
;
12
use
Magento\InventoryApi\Api\SourceRepositoryInterface
;
13
use
Magento\InventoryApi\Api\Data\SourceInterface
;
14
use
Magento\Framework\Api\SearchCriteriaBuilder
;
15
16
class
GetSourceItemsDataBySku
17
{
21
private
$sourceItemRepository;
22
26
private
$sourceRepository;
27
31
private
$searchCriteriaBuilder;
32
39
public
function
__construct
(
40
SourceItemRepositoryInterface
$sourceItemRepository,
41
SourceRepositoryInterface
$sourceRepository,
42
SearchCriteriaBuilder
$searchCriteriaBuilder
43
) {
44
$this->sourceItemRepository =
$sourceItemRepository
;
45
$this->sourceRepository =
$sourceRepository
;
46
$this->searchCriteriaBuilder =
$searchCriteriaBuilder
;
47
}
48
54
public
function
execute
(
string
$sku): array
55
{
56
$sourceItemsData = [];
57
58
$searchCriteria
= $this->searchCriteriaBuilder
59
->addFilter(
SourceItemInterface::SKU
, $sku)
60
->create();
61
$sourceItems
= $this->sourceItemRepository->getList(
$searchCriteria
)->getItems();
62
63
$sourcesCache = [];
64
foreach
(
$sourceItems
as
$sourceItem
) {
65
$sourceCode
=
$sourceItem
->getSourceCode();
66
if
(!isset($sourcesCache[
$sourceCode
])) {
67
$sourcesCache[
$sourceCode
] = $this->sourceRepository->get(
$sourceCode
);
68
}
69
70
$source
= $sourcesCache[
$sourceCode
];
71
72
$sourceItemsData[] = [
73
SourceItemInterface::SOURCE_CODE
=>
$sourceItem
->getSourceCode(),
74
SourceItemInterface::QUANTITY
=>
$sourceItem
->getQuantity(),
75
SourceItemInterface::STATUS
=>
$sourceItem
->getStatus(),
76
SourceInterface::NAME
=>
$source
->getName(),
77
'source_status'
=>
$source
->isEnabled(),
78
];
79
}
80
81
return
$sourceItemsData;
82
}
83
}
Magento\InventoryApi\Api\Data\SourceItemInterface\QUANTITY
const QUANTITY
Definition:
SourceItemInterface.php:27
Magento\InventoryCatalogAdminUi\Model\GetSourceItemsDataBySku
Definition:
GetSourceItemsDataBySku.php:16
Magento\InventoryApi\Api\Data\SourceItemInterface\STATUS
const STATUS
Definition:
SourceItemInterface.php:28
Magento\InventoryCatalogAdminUi\Model\GetSourceItemsDataBySku\execute
execute(string $sku)
Definition:
GetSourceItemsDataBySku.php:54
Magento\Framework\Api\SearchCriteriaBuilder
Definition:
SearchCriteriaBuilder.php:14
$source
$source
Definition:
source.php:23
Magento\InventoryApi\Api\Data\SourceItemInterface\SOURCE_CODE
const SOURCE_CODE
Definition:
SourceItemInterface.php:26
$searchCriteria
$searchCriteria
Definition:
order_rollback.php:16
Magento\InventoryApi\Api\Data\SourceItemInterface
Definition:
SourceItemInterface.php:20
Magento\InventoryCatalogAdminUi\Model\GetSourceItemsDataBySku\__construct
__construct(SourceItemRepositoryInterface $sourceItemRepository, SourceRepositoryInterface $sourceRepository, SearchCriteriaBuilder $searchCriteriaBuilder)
Definition:
GetSourceItemsDataBySku.php:39
$sourceItems
$sourceItems
Definition:
source_items.php:76
$sourceCode
$sourceCode
Definition:
inventory.phtml:11
Magento\InventoryApi\Api\Data\SourceItemInterface\SKU
const SKU
Definition:
SourceItemInterface.php:25
Magento\InventoryApi\Api\Data\SourceInterface
Definition:
SourceInterface.php:17
Magento\InventoryApi\Api\SourceRepositoryInterface
Definition:
SourceRepositoryInterface.php:29
$searchCriteriaBuilder
$searchCriteriaBuilder
Definition:
order_rollback.php:15
Magento\InventoryCatalogAdminUi\Model
Definition:
BulkOperationsConfig.php:8
Magento\InventoryApi\Api\Data\SourceInterface\NAME
const NAME
Definition:
SourceInterface.php:23
$sourceRepository
$sourceRepository
Definition:
source.php:20
Magento\InventoryApi\Api\SourceItemRepositoryInterface
Definition:
SourceItemRepositoryInterface.php:32
$sourceItemRepository
$sourceItemRepository
Definition:
source_items_rollback.php:15
$sourceItem
$sourceItem
Definition:
set_product_bundle_out_of_stock.php:24