Magento: Save products stock movements

With Magento, the stock of a product is not stored each time it’s changing. However, the stock may be modified in many ways (product ordered, canceled order, manual changes, imports, etc..) and it may be useful to know how and when the stock has changed. Here is a simple extension that saves over time the stock movements of your products.

Installation of Stock Movements extension

Extension is available on GitHub:

You have 2 ways to install it:

  1. Download package here, then unzip in Magento root folder.
  2. Installation with modgit:

    $ modgit add stock-movements

    See a full example of how to use modgit here.

Clear Magento cache and that’s it!


Once installed, you can see a new tab in product modification form:

Stock Movements


Extension has been tested on following Magento versions: 1.5.x, 1.6.x, 1.7.x

41 Responses to “Magento: Save products stock movements”

  1. Web,aster says:

    Little change in code. Is buy goods, then usename get “-”
    If we change code to
    $username = ‘-‘;
    if (Mage::getSingleton(‘customer/session’)->isLoggedIn()) {
    $username = Mage::getSingleton(‘customer/session’)->getCustomer()->getEmail();
    } elseif (Mage::getSingleton(‘admin/session’)->isLoggedIn()) {
    $username = Mage::getSingleton(‘admin/session’)->getUser()->getUsername();

    we have user email

  2. kerrigan says:

    On my new webstore (magento 1.7) i got some trouble to install the module.

    I replaced :

    $installer = $this;
    /* @var $installer Mage_Core_Model_Resource_Setup */

    $tableHistory = $this->getTable(‘cataloginventory_stock_history’);
    $tableItem = $this->getTable(‘cataloginventory_stock_item’);
    $tableUser = $this->getTable(‘admin/user’);


    By :

    $installer = $this;
    /* @var $installer Mage_Core_Model_Resource_Setup */

    // $tableHistory = $this->getTable(‘cataloginventory_stock_history’);
    // $tableItem = $this->getTable(‘cataloginventory_stock_item’);
    // $tableUser = $this->getTable(‘admin/user’);

    $tableHistory = $this->getTable(‘cataloginventory_stock_history’);
    $tableItem = $installer->getTable(‘cataloginventory_stock_item’);
    $tableUser = $installer->getTable(‘admin/user’);

    And now it works ;)

  3. Dan says:

    Thanks for the Stock History Extension. Great work! 1.6.2

  4. Vincent Toms says:

    I am running EE 1.10 and seems to install and create the tables, but when I go to look at a product I see the following, then a big stacktrace

    Warning: include(Mage/Core/Model/Resource/Db/Abstract.php): failed to open stream: No such file or directory in /Users/vtoms/dev/adoreme/adoreme/html/lib/Varien/Autoload.php on line 93

    not sure how to debug this on.

    • Johann Reinke says:

      I can’t see a file of mine in the warning. Have you tried disabling my module?

      • Sterling Okura says:

        Thanks for creating this module. I get same error on Pro 1.10. I checked and there is no Db directory in Mage/Core/Model/Resource. So maybe it’s only compatible with community version?

      • Sterling Okura says:

        Looks like that include path works only for 1.6+. In 1.5 or EE 1.10 the model is Mage_Core_Model_Mysql4_Collection_Abstract.

        • JeromeS says:


          I tried to install the module on Magento CE (yeah I know it’s an old version but I’d really like to make this work on this version).

          I made the change you had to make for 1.5, but when I want to go to a product, I get the error
          Fatal error: Call to a member function getReadConnection() on a non-object in /var/www/magento/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php on line 68

          Anyone know If it is possible at all to make this module work on ?

          Thanks a lot for your help.

  5. Lee says:

    Looks great but installed on but get a internal server 500 error when I try to edit a product, might be the Enhanced Product Grid Extension that is installed. I think it would work on a clean install. Uninstalled and can now access the product edit pages again. Any thoughts? Thankyou.

  6. Jason Lamuda says:

    Hi Johann,

    Quick question – when I changed the stock manually to 0 in the admin page, it does not get updated in the stock history.

    Any reason why?


  7. Jorge says:

    Testing in Magento 1.7.2 identified that in one purchase with several items it records only the changes of the last product.

    It is normal behavior or a conflict?

    Thanks and sorry my bad english.

    • Gigirtu Andrei says:

      There its a minor bug which causes this:
      In Model/Observer function checkoutAllSubmitAfter
      $this->insertStockHistory($stockItem, $data['delta'], sprintf(
      ‘Product ordered (order%s: %s)’,
      count($data['orders']) > 1 ? ‘s’ : ”,
      implode(‘, ‘, $data['orders'])

      $this->insertStockHistory($data['item'], $data['delta'], sprintf(
      ‘Product ordered (order%s: %s)’,
      count($data['orders']) > 1 ? ‘s’ : ”,
      implode(‘, ‘, $data['orders'])

  8. Rafal says:

    When duplicating configurable product there is an error:

    Fatal error: Call to a member function addTab() on a non-object in /app/code/community/JR/StockHistory/Model/Stock/Observer.php on line 9

    Great extension

  9. Pete says:

    Great plugin but I notice that the stock history is not recorded when a customer pays with Paypal Express. Is this a problem on my end or is this an expected outcome due to the nature of the way the payment is captured?

  10. Maxi says:

    Hi Johann. First of all, thank you very much! You’ve really help me out with this module.

    I’ve installed it and all seems to be working fine, but for one behaviour: all movements are recorded either twice or three times. Is this normal?

    For eg. this is the log of a product of mine:

    7 0 Sí Product ordered (order: 400000024) – 07/05/2013 16:29:41
    7 -1 Sí Product ordered (order: 400000024) – 07/05/2013 16:29:41
    8 0 Sí Product ordered (order: 400000022-1) maxicooper 07/05/2013 16:25:17
    8 0 Sí Product restocked after order cancellation (order: 400000022) maxicooper 07/05/2013 16:25:17
    8 -2 Sí Stock saved manually maxicooper 07/05/2013 16:25:17
    10 +16 Sí Stock saved manually maxicooper 07/05/2013 16:24:06
    -6 0 No Product ordered (order: 400000022) maxicooper 07/05/2013 16:21:57
    -6 0 No Product ordered (order: 400000022) maxicooper 07/05/2013 16:21:57
    -6 0 No Product ordered (order: 400000022) maxicooper 07/05/2013 16:21:56
    -6 – No Stock saved manually maxicooper 07/05/2013 16:21:55

    Any ideas why? Thanks again!

  11. Livne says:

    Same as Maxi.
    We have many lines repeated. twice or three times for each actions.
    even four.

  12. Johann Reinke says:


    The bug has been fixed (multiple/duplicate lines).
    Update the source code from GitHub:

  13. Aurélien says:


    It’s possible to add an “edit” button on “message” in admin ? I try but I can’t go to the good url :'(

    Your extension is better than mine but I don’t use the same way to print data so I can’t add anything.



  14. Timothy says:

    I have found an issue in your MustHaveExtention. Posted on a github.

  15. Ricardo says:

    Anyone try to install this in magento 1.8?

  16. bbaccessories says:

    Yes, we’d like to know if it works on CE 1.8.1. Anybody done it?

    • Peter Svegrup says:

      To Ricardo and bbaccessories; I have it up and running on CE 1.9 but so far only dev with manual changes to the stock but those look fine. Let me know if you have had a chance to try it out on a production site yet?

      On first stock update for each product there seem to be an error that either sets the movement to the same as the target quantity or nothing, just a dash. Any clue what that could be?

      Thanks in advance

  17. Dan D says:

    I have used this before thanks!
    Now I am trying it with another extension that has multiple stock locations ( Innoexts Multi-warehouse Plus)
    Looks like you assume all stock is in stock_id zero, which works for Magento out of the box.
    What would it take to lok at he stock_id?

  18. David says:

    I am getting
    SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘movement’ in ‘order clause’

    With magento 1.7

    It didn’t install it well?


  19. Hey there! I know this is kinda off topic nevertheless I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My blog discusses a lot of the same topics as yours and I think we could greatly benefit from each other. If you are interested feel free to send me an email. I look forward to hearing from you! Awesome blog by the way!

  20. Masoud says:

    Hi Dear.

    I used this extension and it’s good works.
    Thanks a lot.

    one question.
    How to use tab Stock Movement in another attribute set?

    At the moment, there is only in attribute set default.


  21. Kai-Uwe says:

    Thanks a lot! Thats a big part of what we’re looking for! Now we just need to figure out how to pass a user along when we update stock levels with our custom php-code using the setData-function – any ideas…?

  22. Ko says:

    Hi, does this still work on Magento ver.

  23. Vinicius says:

    Thank you very much! The extension works like a charm!

  24. rlip says:

    The last element on page, don’t has a changes value, and in the multi-product grid the changes column has wrong values (related to previous row, and sometimes with different product) :)

  25. sarker says:

    Thanks a lot. Nice work

  26. JeromeS says:


    Did anyone try to install this on Magento ? For the author : do you know if it works on this (old, I know…) version of Magento ?

    Thanks I would really like to use this extension.


  27. Hi, is it possible to ask for small addition? In stock movement INTO the warehouse to have the price of the unit so we can later generate PROFIT report?

Leave a Reply

* Required fields