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

Page 1 of 2
Display Inventory Qty
 
jhebert
Jr. Member
 
Total Posts:  8
Joined:  2008-03-01
 

Is there a way to show customers an items qty in stock on either the product page or the product list page?

Jason

webdevology.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

try this:

<?=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
jhebert
Jr. Member
 
Total Posts:  8
Joined:  2008-03-01
 

Moshe, you are the man…

Thanks a ton.

Jason

webdevology.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiaraweb
Guru
 
Avatar
Total Posts:  721
Joined:  2008-03-21
Aviano ~ Italy
 

Hy
I’m searching to display the same thing… but I don’t understand what file to edit to put this code…

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 
chiaraweb - 23 March 2008 10:26 PM

Hy
I’m searching to display the same thing… but I don’t understand what file to edit to put this code…

Thanks

./app/design/frontend/default/default/template/catalog/product/view.phtml
or
./app/design/frontend/default/default/template/catalog/product/view/*.phtml

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

Is there a way to display this for the configured options? 

For example once someone decides they want it in Navy, size Small it would display how many Small Navy shirts were available.

You can see where I integrated the quantity into the availability here:
http://store.sherrierohde.com/index.php/guard-pullover-nylon-jacket.html

But it’s just tracking from the main configurable product rather than the simple product being “selected.”

It’s really really slow, I know, it’s on DreamHost temporarily.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiaraweb
Guru
 
Avatar
Total Posts:  721
Joined:  2008-03-21
Aviano ~ Italy
 
gabrielk - 24 March 2008 04:49 PM

chiaraweb - 23 March 2008 10:26 PM
Hy
I’m searching to display the same thing… but I don’t understand what file to edit to put this code…

Thanks

./app/design/frontend/default/default/template/catalog/product/view.phtml
or
./app/design/frontend/default/default/template/catalog/product/view/*.phtml

Thank You

The mod works but I don’t know why I have quantity 5 in inventory but store front shows 5.000 big surprise

http://98.130.130.250/public/shop/index.php/catalog/category/view/mode/grid/id/4/

Is there some code that I can add or anything I can mod to change 5.000 in 5 ?

Thanks a lot

 
Magento Community Magento Community
Magento Community
Magento Community
 
preinheimer
Jr. Member
 
Total Posts:  1
Joined:  2008-02-26
 

You can cast the value to an integer: <?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>

You could look at round for rounding the values to a given precision http://docs.php.net/round

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiaraweb
Guru
 
Avatar
Total Posts:  721
Joined:  2008-03-21
Aviano ~ Italy
 
preinheimer - 26 April 2008 02:58 PM

You can cast the value to an integer: <?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>

You could look at round for rounding the values to a given precision http://docs.php.net/round

Thank You
I resolved changing the attribute of the cell in database from decimals to integer, but I imagine that your way it is better wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
Thejosh13
Sr. Member
 
Total Posts:  252
Joined:  2008-06-23
 

Is there a way to show the QTY select option as a drop down menu with default set to 1?

 
Magento Community Magento Community
Magento Community
Magento Community
 
fabdel
Jr. Member
 
Total Posts:  16
Joined:  2008-08-29
 

See here http://www.magentocommerce.com/boards/viewreply/69618/

 
Magento Community Magento Community
Magento Community
Magento Community
 
craichead
Jr. Member
 
Total Posts:  28
Joined:  2008-08-28
Greeley, CO
 

I would like to display the stock of each item listed on a grouped product page ( grouped.phtml ) .  How would you do this? Thanks.

Edit:  Figured it out:

<?php if($_product->isSaleable()): ?>
<?
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getQty()?>
<?php 
else: ?><?php echo $this->__('Out of Stock'?><?php endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
LarMan128
Jr. Member
 
Total Posts:  14
Joined:  2008-09-14
 
sherrie - 11 April 2008 11:30 AM

Is there a way to display this for the configured options? 

For example once someone decides they want it in Navy, size Small it would display how many Small Navy shirts were available.

You can see where I integrated the quantity into the availability here:
http://store.sherrierohde.com/index.php/guard-pullover-nylon-jacket.html

But it’s just tracking from the main configurable product rather than the simple product being “selected.”

It’s really really slow, I know, it’s on DreamHost temporarily.

does anyone know how to do this? i have this working on simple products by using the code posted above but the configurable products it shows the configurable products quantity. when the options are selected i need it to show how many of that product are in stock so it needs to get the quantity from the associated simple product.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SCY
Member
 
Total Posts:  47
Joined:  2008-12-02
 

Thanks to the great posts and this is a more specific way of how to set it up quickly:

Simple product:

Open app\design\frontend\default\[your_theme]\template\catalog\product\view\type\simple.phtml
Find

<class="availability"><?php echo $this->__('Quantity in stock:'?></p>
Change into
<class="availability"><?php echo $this->__('Quantity in stock:'?><?=(int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?></p>
Save and done!

Grouped produt:

Open app\design\frontend\default\[your_theme]\template\catalog\product\view\type\grouped.phtml
Find

<td class="a-center">
            
<?php if ($_item->isSaleable()) : ?>
                
<input name="super_group[<?php echo $_item->getId() ?>]" value="<?php echo $_item->getQty()*1 ?>" type="text" class="input-text qty" />
            
<?php else: ?>
                <?php 
echo $this->__('Out of stock.'?>
            <?php 
endif; ?>
            
</td>
Insert the following code above it,
<td class="a-center">
            
<?php if($_product->isSaleable()): ?>
                <?
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getQty()?>
            <?php 
else: ?><?php echo $this->__('Out of Stock'?><?php endif; ?> 
            
</td>
Lastly, find:
<thead>
        <
tr>
            <
th><?php echo $this->__('Product Name'?></th>
            <
th class="a-right"><?php echo $this->__('Price'?></th>
            
<?php if ($_product->isSaleable()): ?>
            
<th class="a-center"><?php echo $this->__('Qty'?></th>
            
<?php endif; ?>
        
</tr>
    </
thead>

and change to:

<thead>
        <
tr>
            <
th><?php echo $this->__('Product Name'?></th>
            <
th class="a-right"><?php echo $this->__('Price'?></th>
            <
th class="a-right"><?php echo $this->__('Availability'?></th>
            
<?php if ($_product->isSaleable()): ?>
            
<th class="a-center"><?php echo $this->__('Qty'?></th>
            
<?php endif; ?>
        
</tr>
    </
thead>
You may refer to the screen shot attached.
Image Attachments
display_qty_group_product.gif
 
Magento Community Magento Community
Magento Community
Magento Community
 
nasha
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2009-04-15
 

Does any body know how to show quantity for configurable product in dropdownlist .help me out

 
Magento Community Magento Community
Magento Community
Magento Community
 
itchytrig
Sr. Member
 
Avatar
Total Posts:  162
Joined:  2008-10-03
UK
 

Scyllar,

Hi, your updates to allow stock QTY to show on product pages works a treat, however we would like to extend the displaying of stock to section/search results pages too?

Is this just as quick to apply at all? Is it a case of amending:

/catalog/product/list.phtml

With the correct code? If so what exactly should I do???

Many thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2