Product Availability – Check if Product is Available on Main Website

productstores

When product is not enabled in main website from the backend is there way to find it programmatically?

enter image description here

I have tried this way. But it shows product id(not false)

$product       = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
$productIdMage = $product->getId();

if($productIdMage != false) {
    echo $productIdMage;
}
else{
    echo 'false';
}

Best Answer

That option enables website ids field with product. To check that field, your call should go like this :

$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
var_dump($product->getWebsiteIds());

This will give an array of websites, product is assigned to.