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-sales
Plugin
InventoryApi
StockRepository
PreventDeletingAssignedToSalesChannelsStockPlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventorySales\Plugin\InventoryApi\StockRepository
;
9
10
use
Magento\Framework\Exception\CouldNotDeleteException
;
11
use
Magento\InventoryApi\Api\StockRepositoryInterface
;
12
use
Magento\InventorySalesApi\Model\GetAssignedSalesChannelsForStockInterface
;
13
17
class
PreventDeletingAssignedToSalesChannelsStockPlugin
18
{
22
private
$assignedSalesChannelsForStock;
23
27
public
function
__construct
(
28
GetAssignedSalesChannelsForStockInterface
$assignedSalesChannelsForStock
29
) {
30
$this->assignedSalesChannelsForStock = $assignedSalesChannelsForStock;
31
}
32
42
public
function
beforeDeleteById
(
StockRepositoryInterface
$subject,
int
$stockId)
43
{
44
$assignSalesChannels = $this->assignedSalesChannelsForStock->execute($stockId);
45
if
(count($assignSalesChannels)) {
46
throw
new
CouldNotDeleteException
(
__
(
'Stock has at least one sale channel and could not be deleted.'
));
47
}
48
}
49
}
Magento\InventoryApi\Api\StockRepositoryInterface
Definition:
StockRepositoryInterface.php:26
__
__()
Definition:
__.php:13
Magento\InventorySalesApi\Model\GetAssignedSalesChannelsForStockInterface
Definition:
GetAssignedSalesChannelsForStockInterface.php:18
Magento\InventorySales\Plugin\InventoryApi\StockRepository
Definition:
LoadSalesChannelsOnGetListPlugin.php:8
Magento\InventorySales\Plugin\InventoryApi\StockRepository\PreventDeletingAssignedToSalesChannelsStockPlugin\__construct
__construct(GetAssignedSalesChannelsForStockInterface $assignedSalesChannelsForStock)
Definition:
PreventDeletingAssignedToSalesChannelsStockPlugin.php:27
Magento\InventorySales\Plugin\InventoryApi\StockRepository\PreventDeletingAssignedToSalesChannelsStockPlugin
Definition:
PreventDeletingAssignedToSalesChannelsStockPlugin.php:17
Magento\InventorySales\Plugin\InventoryApi\StockRepository\PreventDeletingAssignedToSalesChannelsStockPlugin\beforeDeleteById
beforeDeleteById(StockRepositoryInterface $subject, int $stockId)
Definition:
PreventDeletingAssignedToSalesChannelsStockPlugin.php:42
Magento\Framework\Exception\CouldNotDeleteException
Definition:
CouldNotDeleteException.php:12