Managing Custom Stock Status – Magento

Apart from the default stock statuses provided by Magneto namely ‘in stock’ and ‘out of stock’, here is how you can manage custom stock statues.

In this example, I have a total of four stock statues namely ‘in stock’, ‘out of stock’, ‘drop ships’ and ‘stock backordered’.

In order to manage the custom stock statues, first – you need to create a custom product attribute via the Magento Admin. I am using the attribute name ‘fulfillment’ in this example; tt would be of type ‘dropdown’ with two options ‘drop ships’ and ‘stock backordered’.

Note that you need to assign this newly created attribute to one of the attribute sets.

Configuration for managing stock status for products

Below are a few scenarios (in regard to – product stock management via Magento Admin), we would display the appropriate stock status for a product, depending on the conditions mentioned below:

  • In Stock: the stock is being managed for this product AND the quantity of the product is greater than zero
  • Out of Stock: stock is being managed for this product AND the quantity of the product is less than or equal to zero
  • Drop Ships: the stock is not being managed AND the ‘fulfillment’ attribute is set to ‘drop ships’
  • Stock Backordered: the stock is not being managed AND the ‘fulfillment’ attribute is set to ‘stock backordered’

 

Displaying stock status on frontend

Now, in the following file,

app / design / frontend / default / YOUR THEME NAME / template / catalog / product / view / type / default.phtml

We can use the code below to override the default Magento behavior to display stock availability.

Notes:

I am assuming that the product is set to ‘out of stock’ if the quantity is less than zero.

Let’s say the quantity in stock for a product is 10. If you change it to 0 (for testing) then, the stock status is automatically set to ‘Out of stock’ by Magento. Now, if you change the quantity to any number greater than zero, Magento does NOT automatically change the stock status to ‘in stock’ hence, you need to manually change the stock status to ‘in stock’.

7 Responses to 'Managing Custom Stock Status – Magento'

  1. Thanks! This is good tutorial.
    Any way to hook such custom stock options with configurable products? For example, to show configurable product option and then this custom stock message?
    Red – In stock
    Black – Backorder
    Green – Dropship

    John

    Nov 14, 2011

  2. Hi,

    Thanks for the post, looks like just what I need. I’ve tried but it seems this code is out of date maybe due to upgrades of Magento?

    I’ve tried copying this exactly and it throws a 500 server error so had to revert. Could you clear this up please as I would like to implement this.

    Thanks again for sharing your code and ideas with us :)

    Regards,
    Matt.

    Matt

    Aug 6, 2012

  3. It keeps giving me this fatab error:
    Fatal error: Call to a member function getStockItem() on a non-object in C:\wamp\www\a2\app\design\frontend\customtheme\default\template\catalog\product\view\type\default.phtml on line 4

    I don’t have any clue what is wrong.If you cand give me a hint ..
    I use magento 1.6.2.0

    Regards

    soryn

    Oct 25, 2012

  4. Regarding: “Let’s say the quantity in stock for a product is 10. If you change it to 0 (for testing) then, the stock status is automatically set to ‘Out of stock’ by Magento. Now, if you change the quantity to any number greater than zero, Magento does NOT automatically change the stock status to ‘in stock’ hence, you need to manually change the stock status to ‘in stock’.”

    Is there a fix for this – to have Magento update the “out of stock” when there is inventory allocated?

    Mangesh

    Nov 1, 2012

  5. that’s really usefull. customers began to value our store when they see they are cared for. and to show more info about stock on the frontend to customer we use this module http://amasty.com/custom-stock-status.html. I did’t want to buy it but then saw all the features and decided to try. the thing is now i change stock statuses in different ways for dif products (‘available tomorrow’ or ‘delivery in 4 days’) and use alerts for options of configurables. it works! now wanna recommend to everyone

    Lindy

    Mar 21, 2013

  6. You need to make sure the Attribute is Frontend Visible, in Attribute settings. Then change the if ($_product->getAttributeText(‘fulfillment’)

    to

    if ($_product->getData(‘fulfillment’)

    Works perfect 1.7.0.2

    Mike

    Jul 15, 2013

  7. Mike,

    I’ve made the changes you’ve stated.. Still won’t display.

    Attributes:
    Scope = Global
    Catalog Inpute Type for Store Owner = Dropdown
    Unique Value = No
    Values Required = No
    Input Validation for Store Owner = None
    Apply To = All Product Types
    Use To Create Configurable Product = Yes

    Visibile on Product View Page on Front-end = Yes

    What do I need to change?

    eric

    May 12, 2014

Leave a Comment