Magento Forum

   
Page 1 of 2
Show inventory levels
 
inogenius
Jr. Member
 
Total Posts:  3
Joined:  2008-02-23
 

Hi Everyone,

I’m creating a site where we’ll be keeping low stock levels due to the slow churn rate of the product. But I have a number of outside distributors setup who will always need to know the inventory levels that we have. Is there a way to add this to the product page, or anything? The current “IN STOCK” or “OUT OF STOCK” just isn’t quite detailed enough, as we may only have 1 product in stock, and they have an order for 3.

 
Magento Community Magento Community
Magento Community
Magento Community
 
msohler
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

Yes, I need the same thing, they have uniquely died yarns and only have 5 so they want to show how many are available to purchase.  It seem like it could be added in the custom design area of the product itself.  But I don’t know the xml code to use.

 
Magento Community Magento Community
Magento Community
Magento Community
 
The Sunday Paper
Sr. Member
 
Total Posts:  202
Joined:  2008-08-06
 

I display it on <a href="http://halfoffdepot.com">my site</a> using this:

<?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>

in code/frontend/.../template/catalog/product/view.phtml.

 
Magento Community Magento Community
Magento Community
Magento Community
 
msohler
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

this worked great I even added some text and I am not a php programmer
<?php $myString = "Available Inventory: "; echo $myString;?>

How would I get this to show for only 2 categories - everything else in the store does not need an inventory.
I need an IF statement based on category number id.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Frederik Krautwald
Member
 
Avatar
Total Posts:  58
Joined:  2007-09-25
Reykjavík, Iceland
 

Is there a way to do this for configurable products?

 
Magento Community Magento Community
Magento Community
Magento Community
 
msohler
Jr. Member
 
Total Posts:  12
Joined:  2008-08-14
 

I was able to creat this so far:

<?php $myString = "Available Inventory!"; ?>
<?php if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()<100)
echo $myString;
else (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()
?>
<?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>

However I want either one or the other to display not both: which is what its doing now for an item with less than 100 stock

either this if less than 100 in stock

Available Inventory! 2

or this if stock is over 100,
Availability: In stock.

but I can’t get the syntax right on the if statement, any help? thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
ShopMagCart
Member
 
Total Posts:  70
Joined:  2009-01-04
 
msohler - 11 February 2009 02:58 PM

I was able to creat this so far:

<?php $myString = "Available Inventory!"; ?>
<?php if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()<100)
echo $myString;
else (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()
?>
<?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>


However I want either one or the other to display not both: which is what its doing now for an item with less than 100 stock

either this if less than 100 in stock

Available Inventory! 2

or this if stock is over 100,
Availability: In stock.

but I can’t get the syntax right on the if statement, any help? thanks

Any luck on getting the if statement to work correctly?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Compuland
Guru
 
Total Posts:  374
Joined:  2009-01-14
Denmark
 

HI.

Is there a way to get it to use a attribute?. I made one with delivery time. It could be nice to have show it together with not in stock.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Deicard
Jr. Member
 
Total Posts:  2
Joined:  2009-11-14
 

Greetings,

Found this thread pretty interesting.

For those of you which do not want the current code to show up when an item has zero inventory be it digital product or the likes consider the following.

<?php $stale_qty 1?>
            <?php 
if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() >= $stale_qty):?>
                            <?php $DisplayAvailale 
"Available:"; echo $DisplayAvailale?>
                            <?
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
            <?php 
else:?>
            <?php 
endif; ?>

The above if statement grabs the gty number from magento and then checks to see if it greater than or equal to 1. Which case it will display how many product are available if there is an actual number other then zero. The reason I have edited it is due to the fact that products which sell out list themselves as ‘out of stock’ and digital media will show a zero when listed. Anything which you do not need to manage stock will show a zero, this making this a simple fix for the time being. If you want to add something to the if statement, I left in an else function so you can add something.

This uses a stale int for the if statement, not the best way for this.

<?php $stale_qty 1?>

However this is the fix I am using until I get around to hooking it to an attribute inside of hard coding it in local script.  downer

Also this is now located in

/public_html/DIR/app/design/frontend/default/default/template/catalog/product
Called view.phtml, you will need to start editing on around Ln69. DIR being any said directory you have installed Magneto in.

____________________

For the person which wanted to show this only when the stock was between 1 and 100 try the following

<?php $stale_max_qty 100?>
            <?php $stale_min_qty 
1?>
            <?php 
if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() >= $stale_min_qty && (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() <= $stale_max_qty ):?>
                            <?php $DisplayAvailale 
"Available:"; echo $DisplayAvailale?>
                            <?
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
            <?php 
else:?>
            <?php 
endif; ?>

Above uses an ‘and’ function to make it so that it has to be around one or greater and 100 or less. If it is not either then it is now displayed.

Currently I have this thread notifying me when someone posts.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Compuland
Guru
 
Total Posts:  374
Joined:  2009-01-14
Denmark
 
Deicard - 14 November 2009 05:34 AM

Greetings,

Found this thread pretty interesting.

For those of you which do not want the current code to show up when an item has zero inventory be it digital product or the likes consider the following.

<?php $stale_qty 1?>
            <?php 
if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() >= $stale_qty):?>
                            <?php $DisplayAvailale 
"Available:"; echo $DisplayAvailale?>
                            <?
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
            <?php 
else:?>
            <?php 
endif; ?>

The above if statement grabs the gty number from magento and then checks to see if it greater than or equal to 1. Which case it will display how many product are available if there is an actual number other then zero. The reason I have edited it is due to the fact that products which sell out list themselves as ‘out of stock’ and digital media will show a zero when listed. Anything which you do not need to manage stock will show a zero, this making this a simple fix for the time being. If you want to add something to the if statement, I left in an else function so you can add something.

This uses a stale int for the if statement, not the best way for this.

<?php $stale_qty 1?>

However this is the fix I am using until I get around to hooking it to an attribute inside of hard coding it in local script.  downer

Also this is now located in
/public_html/DIR/app/design/frontend/default/default/template/catalog/product
Called view.phtml, you will need to start editing on around Ln69. DIR being any said directory you have installed Magneto in.

____________________

For the person which wanted to show this only when the stock was between 1 and 100 try the following

<?php $stale_max_qty 100?>
            <?php $stale_min_qty 
1?>
            <?php 
if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() >= $stale_min_qty && (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() <= $stale_max_qty ):?>
                            <?php $DisplayAvailale 
"Available:"; echo $DisplayAvailale?>
                            <?
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
            <?php 
else:?>
            <?php 
endif; ?>

Above uses an ‘and’ function to make it so that it has to be around one or greater and 100 or less. If it is not either then it is now displayed.

Currently I have this thread notifying me when someone posts.

hi Deicard

Thanks you for looking into this.

I’m sorry but i’m not a coder just one who would like to make a magento shop.
I’m not sure if i get what your trying to explain here. the code you made is different from the the other code in which way?.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Deicard
Jr. Member
 
Total Posts:  2
Joined:  2009-11-14
 

The Sunday Paper, shows how to display a number in general related to the qty of items to the product.
msohler posted, tried making an if statement. Had a problem with syntax.
ShopMagCart posted, also asked for an if statement.

What I posted was the if statement I am using, since msohler has some problems with syntax. Along with displaying simple text. All sunday paper showed was how to call the gty of the product. While if you just use the qty output (what The Sunday Paper showed) and decide to sell a digital product, or a product you have no managed inventory for, it will output an zero. This statement does not do that; if the QTY of the product is zero it will not display a zero on the product page or print out ‘Available’.

After that, Msohler was really posting about an if statement which only show up for products between 1 and 100, which I showed an if statement with the and function.
_______________

Nothing to do with grabbing a user defined attributed yet. Compuland, you were talking about possibly an attribute you could apply to all products that would read ‘show qty:’ and options yes or not? Which case for individual shown product it will show how many are available?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Compuland
Guru
 
Total Posts:  374
Joined:  2009-01-14
Denmark
 
Deicard - 14 November 2009 06:36 AM

The Sunday Paper, shows how to display a number in general related to the qty of items to the product.
msohler posted, tried making an if statement. Had a problem with syntax.
ShopMagCart posted, also asked for an if statement.

What I posted was the if statement I am using, since msohler has some problems with syntax. Along with displaying simple text. All sunday paper showed was how to call the gty of the product. While if you just use the qty output (what The Sunday Paper showed) and decide to sell a digital product, or a product you have no managed inventory for, it will output an zero. This statement does not do that; if the QTY of the product is zero it will not display a zero on the product page or print out ‘Available’.

After that, Msohler was really posting about an if statement which only show up for products between 1 and 100, which I showed an if statement with the and function.
_______________

Nothing to do with grabbing a user defined attributed yet. Compuland, you were talking about possibly an attribute you could apply to all products that would read ‘show qty:’ and options yes or not? Which case for individual shown product it will show how many are available?

Hi again

Thanks for you taking your time to explain. I understand it now smile

What i was asking for was the ability to use a attribute showing a delivery time, when a product if out of stock.
like: Quantity in stock: 0. In stock in 3-5 days

 
Magento Community Magento Community
Magento Community
Magento Community
 
sean14538
Member
 
Avatar
Total Posts:  32
Joined:  2009-11-04
Gouldsboro, PA
 

Hello all,
I carry 1 of a kind items, so the inventory is always 1. I would like something similar to this code, but to display in the category menues next to the title, how many products are in the category, it seems that it would be similar to this code, can anybody help me out?
Thanks,
Sean

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  899
Joined:  2008-10-21
 

When you have only 1 left in stock and you want to show it.

<?php if ((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()==1): ?>
<p style="color:#990000; padding:5px 0; text-align:right;"><strong>ONLY 1 LEFT IN STOCK!</strong></p>
<?php endif; ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
tylerhale
Jr. Member
 
Total Posts:  5
Joined:  2010-08-16
 

These posts are great, but it seems like it works only for simple products?  I need to have a grouped product display each inventory level.  I am selling shirts, each shirt size needs to have its own inventory appear next to the quantity box.  Any ideas?  Help is greatly appreciated in advance, thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
tylerhale
Jr. Member
 
Total Posts:  5
Joined:  2010-08-16
 

I found this thread which solved my question about inventory displaying on grouped products:
http://www.magentocommerce.com/boards/viewthread/3980/

Problem solved, thank you Wiki and everyone contributing.

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