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
Model
GetSkusByProductIds.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalog\Model
;
9
10
use
Magento\Catalog\Api\Data\ProductInterface
;
11
use
Magento\Catalog\Model\ResourceModel\Product
as
ProductResourceModel
;
12
use
Magento\Framework\Exception\NoSuchEntityException
;
13
use
Magento\InventoryCatalogApi\Model\GetSkusByProductIdsInterface
;
14
18
class
GetSkusByProductIds
implements
GetSkusByProductIdsInterface
19
{
23
private
$productResource;
24
28
public
function
__construct
(
29
ProductResourceModel
$productResource
30
) {
31
$this->productResource =
$productResource
;
32
}
33
37
public
function
execute
(array
$productIds
): array
38
{
39
$skuByIds = array_column(
40
$this->productResource->getProductsSku(
$productIds
),
41
ProductInterface::SKU
,
42
'entity_id'
43
);
44
$notFoundedIds = array_diff(
$productIds
, array_keys($skuByIds));
45
46
if
(!empty($notFoundedIds)) {
47
throw
new
NoSuchEntityException
(
48
__
(
'Following products with requested ids were not found: %1'
, implode($notFoundedIds,
', '
))
49
);
50
}
51
52
$skuByIds = array_map(
'strval'
, $skuByIds);
53
return
$skuByIds;
54
}
55
}
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
__
__()
Definition:
__.php:13
$productResource
$productResource
Definition:
product_for_search_rollback.php:18
Magento\Catalog\Api\Data\ProductInterface\SKU
const SKU
Definition:
ProductInterface.php:19
Magento\InventoryCatalog\Model\GetSkusByProductIds
Definition:
GetSkusByProductIds.php:18
Magento\InventoryCatalogApi\Model\GetSkusByProductIdsInterface
Definition:
GetSkusByProductIdsInterface.php:16
Magento\InventoryCatalog\Model\GetSkusByProductIds\__construct
__construct(ProductResourceModel $productResource)
Definition:
GetSkusByProductIds.php:28
Magento\InventoryCatalog\Model
Definition:
BulkInventoryTransfer.php:8
$productIds
$productIds
Definition:
product_with_multiple_options.php:11
Magento\Catalog\Api\Data\ProductInterface
Definition:
ProductInterface.php:14
Magento\InventoryCatalog\Model\GetSkusByProductIds\execute
execute(array $productIds)
Definition:
GetSkusByProductIds.php:37
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16