6 declare(strict_types=1);
26 private $messageManager;
31 private $getAssignedSalesChannelsForStock;
41 $this->messageManager = $messageManager;
42 $this->getAssignedSalesChannelsForStock = $getAssignedSalesChannelsForStock;
60 $unAssignedSalesChannels = $this->getUnassignedSalesChannelsForStock(
$stock);
62 if (count($unAssignedSalesChannels)) {
63 $this->messageManager->addNoticeMessage(
64 __(
'All unassigned sales channels will be assigned to the Default Stock')
79 $newWebsiteCodes =
$result = [];
80 $assignedSalesChannels = $this->getAssignedSalesChannelsForStock->execute((
int)
$stock->getStockId());
84 foreach ($newSalesChannels as $salesChannel) {
86 $newWebsiteCodes[] = $salesChannel->getCode();
90 foreach ($assignedSalesChannels as $salesChannel) {
92 && !in_array($salesChannel->getCode(), $newWebsiteCodes,
true)
__construct(ManagerInterface $messageManager, GetAssignedSalesChannelsForStockInterface $getAssignedSalesChannelsForStock)
afterSave(StockRepositoryInterface $subject, int $stockId, StockInterface $stock)