0

i want to show Availability label "In Stock" or "Out Of stock" in my homepage product display. do you know how to do this? thankyou

enter image description here

1 Answer 1

1

Try This

// $_item->getProductId() -> your product id
$product = Mage::getModel('catalog/product')->load($_item->getProductId());

if ($product->getStockItem()->getIsInStock()) { 
    // $product->getStockItem()->getIsInStock() == 1
    echo "product is in stock";
}else{
    // $product->getStockItem()->getIsInStock() == 0
    echo "product is not in stock";
}

**Method 2**

$stockItem = $product->getStockItem();
if($stockItem->getIsInStock())
{
    //in stock!
}
else
{
    //not in stock!
}
4
  • thanks for you answer, but where i can find the code?
    – Ruri
    Mar 21, 2016 at 14:58
  • You add this code in your phtml file
    – Magento 2
    Mar 21, 2016 at 15:07
  • what phtml? catalog/product/list.phtml? catalog/product/view.phtml?
    – Ruri
    Mar 21, 2016 at 15:16
  • which phtml you call home page there you have to place
    – Magento 2
    Mar 21, 2016 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.