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
Store
Model
ResourceModel
Website
UpdateSalesChannelWebsiteCodePlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventorySales\Plugin\Store\Model\ResourceModel\Website
;
9
10
use
Magento\Framework\Exception\CouldNotSaveException
;
11
use
Magento\Framework\Exception\NoSuchEntityException
;
12
use
Magento\Framework\Model\AbstractModel
;
13
use
Magento\Framework\Validation\ValidationException
;
14
use
Magento\InventorySales\Model\ResourceModel\GetWebsiteCodeByWebsiteId
;
15
use
Magento\InventorySales\Model\ResourceModel\UpdateSalesChannelWebsiteCode
;
16
use
Magento\Store\Api\Data\WebsiteInterface
;
17
use
Magento\Store\Model\ResourceModel\Website
as
WebsiteResourceModel
;
18
use
Magento\Store\Model\Website
;
19
20
class
UpdateSalesChannelWebsiteCodePlugin
21
{
25
private
$updateSalesChannelWebsiteCode;
26
30
private
$getWebsiteCodeByWebsiteId;
31
36
public
function
__construct
(
37
UpdateSalesChannelWebsiteCode
$updateSalesChannelWebsiteCode,
38
GetWebsiteCodeByWebsiteId
$getWebsiteCodeByWebsiteId
39
) {
40
$this->updateSalesChannelWebsiteCode = $updateSalesChannelWebsiteCode;
41
$this->getWebsiteCodeByWebsiteId = $getWebsiteCodeByWebsiteId;
42
}
43
54
public
function
aroundSave
(
55
WebsiteResourceModel
$subject,
56
callable $proceed,
57
AbstractModel
$website
58
) {
59
$newCode =
$website
->getCode();
60
$oldCode =
null
;
61
62
if
(
null
!==
$website
->getId()) {
63
$oldCode = $this->getWebsiteCodeByWebsiteId->execute((
int
)
$website
->getId());
64
}
65
66
$result
= $proceed(
$website
);
67
68
if
(($oldCode !==
null
) && ($oldCode !==
WebsiteInterface::ADMIN_CODE
) && ($oldCode !== $newCode)) {
69
$this->updateSalesChannelWebsiteCode->execute($oldCode, $newCode);
70
}
71
return
$result
;
72
}
73
}
Magento\Framework\Model\AbstractModel
Definition:
AbstractModel.php:19
$result
$result
Definition:
product_configurable_not_available_rollback.php:26
Magento\Store\Api\Data\WebsiteInterface\ADMIN_CODE
const ADMIN_CODE
Definition:
WebsiteInterface.php:19
Magento\Store\Model\ResourceModel\Website
Definition:
Collection.php:6
$website
$website
Definition:
payment_configuration_rollback.php:38
Magento\InventorySales\Model\ResourceModel\GetWebsiteCodeByWebsiteId
Definition:
GetWebsiteCodeByWebsiteId.php:15
Magento\Store\Model\Website
Definition:
Website.php:26
Magento\InventorySales\Model\ResourceModel\UpdateSalesChannelWebsiteCode
Definition:
UpdateSalesChannelWebsiteCode.php:18
Magento\Store\Api\Data\WebsiteInterface
Definition:
WebsiteInterface.php:14
Magento\InventorySales\Plugin\Store\Model\ResourceModel\Website\UpdateSalesChannelWebsiteCodePlugin\aroundSave
aroundSave(WebsiteResourceModel $subject, callable $proceed, AbstractModel $website)
Definition:
UpdateSalesChannelWebsiteCodePlugin.php:54
Magento\InventorySales\Plugin\Store\Model\ResourceModel\Website\UpdateSalesChannelWebsiteCodePlugin
Definition:
UpdateSalesChannelWebsiteCodePlugin.php:20
Magento\Framework\Validation\ValidationException
Definition:
ValidationException.php:21
Magento\InventorySales\Plugin\Store\Model\ResourceModel\Website\UpdateSalesChannelWebsiteCodePlugin\__construct
__construct(UpdateSalesChannelWebsiteCode $updateSalesChannelWebsiteCode, GetWebsiteCodeByWebsiteId $getWebsiteCodeByWebsiteId)
Definition:
UpdateSalesChannelWebsiteCodePlugin.php:36
Magento\InventorySales\Plugin\Store\Model\ResourceModel\Website
Definition:
AssignWebsiteToDefaultStockPlugin.php:8
Magento\Framework\Exception\CouldNotSaveException
Definition:
CouldNotSaveException.php:13
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16