Magento – How to Check if the SKU is Exist?

Hello Friends today I will share with you In Magento – How to Check if the SKU is Exist?

$sku = 'Your Product Sku';
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if ($id){
    echo "SKU {$sku} exists";
}
else{
    echo "SKU {$sku} does not exist";
}

Where this code will 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.
Advertisements

2 thoughts on “Magento – How to Check if the SKU is Exist?

Leave your comments

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s