Skip to content

Commit 5818efe

Browse files
oleksandrkravchuknovikor
authored andcommitted
Remove excess code and TODO's.
1 parent bd4adc8 commit 5818efe

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

InventoryBundleProduct/Plugin/InventorySales/IsBundleProductSalable.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,17 @@ public function aroundExecute(
7878
int $stockId
7979
): bool {
8080
try {
81-
$types = $this->getProductTypesBySkus->execute([$sku]);
82-
8381
$isProductSalable = $proceed($sku, $stockId);
84-
if (!isset($types[$sku]) || $types[$sku] !== Type::TYPE_CODE || !$isProductSalable) {
82+
if (!$isProductSalable) {
8583
return $isProductSalable;
8684
}
8785

88-
// TODO: remove in https://github.com/magento/inventory/issues/3201
89-
// Product salability MUST NOT BE CALLED during product load.
90-
// Tests stabilization.
91-
/** @var \Magento\Framework\Registry $registry */
92-
$registry = ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
93-
$key = 'inventory_check_product' . $sku;
94-
95-
if ($registry->registry($key)) {
96-
$product = $registry->registry($key);
97-
} else {
98-
$product = $this->productRepository->get($sku);
86+
$types = $this->getProductTypesBySkus->execute([$sku]);
87+
if (!isset($types[$sku]) || $types[$sku] !== Type::TYPE_CODE) {
88+
return $isProductSalable;
9989
}
10090

91+
$product = $this->productRepository->get($sku);
10192
/** @noinspection PhpParamsInspection */
10293
$options = $this->bundleProductType->getOptionsCollection($product);
10394
$status = $this->getBundleProductStockStatus->execute(

InventoryConfigurableProduct/Plugin/InventorySales/IsConfigurableProductSalable.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,18 @@ public function aroundExecute(
8080
int $stockId
8181
): bool {
8282
try {
83-
$types = $this->getProductTypesBySkus->execute([$sku]);
84-
8583
$isProductSalable = $proceed($sku, $stockId);
86-
if (!isset($types[$sku]) || $types[$sku] !== Configurable::TYPE_CODE || !$isProductSalable) {
84+
if (!$isProductSalable) {
8785
return $isProductSalable;
8886
}
8987

90-
// TODO: remove in https://github.com/magento/inventory/issues/3201
91-
// Product salability MUST NOT BE CALLED during product load.
92-
// Tests stabilization.
93-
/** @var \Magento\Framework\Registry $registry */
94-
$registry = ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
95-
$key = 'inventory_check_product' . $sku;
96-
97-
if ($registry->registry($key)) {
98-
$product = $registry->registry($key);
99-
} else {
100-
$product = $this->productRepository->get($sku);
88+
$types = $this->getProductTypesBySkus->execute([$sku]);
89+
if (!isset($types[$sku]) || $types[$sku] !== Configurable::TYPE_CODE) {
90+
return $isProductSalable;
10191
}
10292

93+
$product = $this->productRepository->get($sku);
10394
$resultStatus = false;
104-
// TODO: remove in https://github.com/magento/inventory/issues/3201
105-
$product->unsetData('_cache_instance_used_product_attributes');
106-
$product->unsetData('_cache_instance_configurable_attributes');
10795
$options = $this->configurableProductType->getConfigurableOptions($product);
10896
$skus = [[]];
10997
foreach ($options as $attribute) {

0 commit comments

Comments
 (0)