How to display the quantity of products in stock on the Magento 1 front end product page

This is how you enable the display of the quantity of products in inventory on the front end product page.

Open /app/design/frontend/default/YOURTHEME/template/catalog/product/view.phtml

In there you can paste this code anywhere you would like the stock quantity to display:

<?php if ($_product->isAvailable()): ?>
    <p class="availability in-stock"><?php echo $this->__('Qty Available:') ?> <span><!--<?php echo $this->__('In stock') ?>--><?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?></span></p>
<?php else: ?>
    <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>

Magento category with products that have stock greater than 0

We had to modify the code we used for this Magento category with all products except out of stock products

Change this part

$inStockProductIds = array();

$inStockCollection = Mage::getModel(‘cataloginventory/stock’)
array( ‘eq’ => 1 )

To this

$inStockCollection = Mage::getModel('cataloginventory/stock')
->addQtyFilter('>', 0)