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
GetProductIdsBySkus.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\Model\ResourceModel\Product
as
ProductResourceModel
;
11
use
Magento\Framework\Exception\NoSuchEntityException
;
12
use
Magento\InventoryCatalogApi\Model\GetProductIdsBySkusInterface
;
13
17
class
GetProductIdsBySkus
implements
GetProductIdsBySkusInterface
18
{
22
private
$productResource;
23
27
public
function
__construct
(
28
ProductResourceModel
$productResource
29
) {
30
$this->productResource =
$productResource
;
31
}
32
36
public
function
execute
(array
$skus
): array
37
{
38
$idsBySkus = $this->productResource->getProductsIdsBySkus(
$skus
);
39
$notFoundedSkus = array_diff(
$skus
, array_keys($idsBySkus));
40
41
if
(!empty($notFoundedSkus)) {
42
throw
new
NoSuchEntityException
(
43
__
(
'Following products with requested skus were not found: %1'
, implode($notFoundedSkus,
', '
))
44
);
45
}
46
47
return
$idsBySkus;
48
}
49
}
Magento\InventoryCatalog\Model\GetProductIdsBySkus\__construct
__construct(ProductResourceModel $productResource)
Definition:
GetProductIdsBySkus.php:27
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
__
__()
Definition:
__.php:13
$skus
foreach($websiteCodes as $websiteCode) $skus
Definition:
assign_products_to_websites.php:23
Magento\InventoryCatalog\Model\GetProductIdsBySkus\execute
execute(array $skus)
Definition:
GetProductIdsBySkus.php:36
$productResource
$productResource
Definition:
product_for_search_rollback.php:18
Magento\InventoryCatalogApi\Model\GetProductIdsBySkusInterface
Definition:
GetProductIdsBySkusInterface.php:16
Magento\InventoryCatalog\Model\GetProductIdsBySkus
Definition:
GetProductIdsBySkus.php:17
Magento\InventoryCatalog\Model
Definition:
BulkInventoryTransfer.php:8
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16