Skip to content

Instantly share code, notes, and snippets.

@denishvachhani
Last active August 29, 2015 13:57
Show Gist options
  • Save denishvachhani/9777761 to your computer and use it in GitHub Desktop.
Save denishvachhani/9777761 to your computer and use it in GitHub Desktop.
Magento – How to Check if the SKU is Exist?
<?php
$sku = 'Your Product Sku';
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if ($id){
echo "SKU {$sku} exists";
}
else{
echo "SKU {$sku} does not exist";
}
?>
@denishvachhani
Copy link
Author

In 3 options above code will be useful

When you import magento products via code then this code is very useful.
If you want to load product via sku then this is very useful.
if you want to update any particular product via code then also this is useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment