Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Available Quantity to Product Description page
 
Gnolaum
Jr. Member
 
Total Posts:  22
Joined:  2008-03-20
 

I’m setting up a store that deals with collectible gaming pieces, where order multiples is a common practice, and as such rather than simply displaying whether the product is in stock or not, I would like to display the available stock.

For instance on the Product Description Page:

<name>
<review link>
Availability: In/Out of Stock -> changed to # available
QTY: [ ] ADD TO CART

Now I see where the change needs to be made: app/design/fronend/default/default/template/catalog/product/view/typ/simple.phtml

lines 45-50:
<?php if($_product->isSaleable()): ?>
<p><small><?php echo $this->__('Availability: In stock.') ?></small></p>
<?php else: ?>
<p><small><?php echo $this->__('Availability: Out of stock.') ?></small></p>
<?php endif; ?>

But I need some sort of $_product->getAvailableStock() stock function, which I cannot find.

Does such a function exist?  How might I find it?  Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_w
Sr. Member
 
Total Posts:  290
Joined:  2008-01-04
 

Try using:
<?php echo Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() ?>. It will load the product quantity for a simple product. Note that since qty is stored as a decimal in the db, you may need to clean up the output.

Dan

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

There is quite a bit of discussion on this fuction here: http://www.magentocommerce.com/boards/viewthread/3980/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top