Skip to content

Commit 24ed2f8

Browse files
author
syam.sg
committed
issue-39329-Invalid SKU Handling for Linked Products in Magento
1 parent 6acfd6a commit 24ed2f8

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ public function execute()
139139
}
140140

141141
$originalSku = $product->getSku();
142+
if($originalSku == 0){
143+
throw new \Magento\Framework\Exception\LocalizedException(__("SKU cannot be zero."));
144+
}
142145
$canSaveCustomOptions = $product->getCanSaveCustomOptions();
143146
$product->save();
144147
$this->handleImageRemoveError($data, $product->getId());

app/code/Magento/Catalog/Model/ProductLink/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function save(\Magento\Catalog\Api\Data\ProductLinkInterface $entity)
139139
. 'Please ensure the parent product SKU is provided and try again.'
140140
));
141141
}
142-
if (!$entity->getLinkedProductSku()) {
142+
if ($entity->getLinkedProductSku() === null || $entity->getLinkedProductSku() === '') {
143143
throw new CouldNotSaveException(__('The linked product SKU is invalid. Verify the data and try again.'));
144144
}
145145
$linkedProduct = $this->productRepository->get($entity->getLinkedProductSku());

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,3 +868,4 @@ Details,Details
868868
"Add To Compare","Add To Compare"
869869
"Learn more","Learn more"
870870
"Recently Viewed","Recently Viewed"
871+
"SKU cannot be zero.","SKU cannot be zero."

0 commit comments

Comments
 (0)