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-low-quantity-notification-api
Test
_files
enable_manage_stock_for_products.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
use
Magento\Catalog\Api\ProductRepositoryInterface
;
9
use
Magento\CatalogInventory\Api\StockItemRepositoryInterface
;
10
use
Magento\TestFramework\Helper\Bootstrap
;
11
12
$objectManager
= Bootstrap::getObjectManager();
13
15
$productRepository
=
$objectManager
->get(ProductRepositoryInterface::class);
16
$stockItemRepository
=
$objectManager
->get(StockItemRepositoryInterface::class);
17
18
$skus
= [
'SKU-1'
,
'SKU-2'
,
'SKU-3'
];
19
20
foreach
(
$skus
as $sku) {
21
$product
=
$productRepository
->get($sku);
22
23
$stockItem
=
$product
->getExtensionAttributes()->getStockItem();
24
$stockItem
->setUseConfigManageStock(
false
);
25
$stockItem
->setManageStock(
true
);
26
27
$stockItemRepository
->save(
$stockItem
);
28
}
$stockItemRepository
$stockItemRepository
Definition:
enable_manage_stock_for_products.php:16
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
$skus
$skus
Definition:
enable_manage_stock_for_products.php:18
$objectManager
$objectManager
Definition:
enable_manage_stock_for_products.php:12
$stockItem
$stockItem
Definition:
configurable_options_advanced_inventory.php:24
$productRepository
$productRepository
Definition:
enable_manage_stock_for_products.php:15
Magento\Catalog\Api\ProductRepositoryInterface
Definition:
ProductRepositoryInterface.php:14
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
Magento\CatalogInventory\Api\StockItemRepositoryInterface
Definition:
StockItemRepositoryInterface.php:17