Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
issue-39329-Invalid SKU Handling for Linked Products in Magento
  • Loading branch information
Syamsg committed Nov 6, 2024
commit 24ed2f83561a1093b79dc50402b49a330298f954
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public function execute()
}

$originalSku = $product->getSku();
if($originalSku == 0){
throw new \Magento\Framework\Exception\LocalizedException(__("SKU cannot be zero."));
}
$canSaveCustomOptions = $product->getCanSaveCustomOptions();
$product->save();
$this->handleImageRemoveError($data, $product->getId());
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/ProductLink/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function save(\Magento\Catalog\Api\Data\ProductLinkInterface $entity)
. 'Please ensure the parent product SKU is provided and try again.'
));
}
if (!$entity->getLinkedProductSku()) {
if ($entity->getLinkedProductSku() === null || $entity->getLinkedProductSku() === '') {
throw new CouldNotSaveException(__('The linked product SKU is invalid. Verify the data and try again.'));
}
$linkedProduct = $this->productRepository->get($entity->getLinkedProductSku());
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -868,3 +868,4 @@ Details,Details
"Add To Compare","Add To Compare"
"Learn more","Learn more"
"Recently Viewed","Recently Viewed"
"SKU cannot be zero.","SKU cannot be zero."