Categories
Magento

Magento – Check if Product Exists by Getting Product ID from SKU

[php]

$productSku = ‘SKU-Of-The-Product’;
// Get Magento product ID by providing the SKU
$productId = Mage::getModel(‘catalog/product’)->getIdBySku($productSku);
// Check if a product ID was returned
if ($productId) {
// Product with SKU $productSku exists
} else {
// Product with SKU $productSku does not exist
}

[/php]