Magento : Enregistrer les mouvements de stock de vos produits

Dans Magento, le stock d’un produit n’est pas sauvegardé au fil du temps. Or, le stock peut être modifié de multiples façons différentes (produit commandé, commande annulée, modification manuelle, imports, etc.) et il peut être utile de savoir d’où viennent les modifications. Voici une extension simple qui sauvegarde au fil du temps les mouvements de stock de vos produits.

Installation de l’extension Stock Movements

L’extension Stock Movements est disponible sur GitHub : https://github.com/jreinke/magento-stock-movements

Pour l’installer, 2 solutions s’offrent à vous :

  1. Téléchargez le package ici, puis désarchivez le à la racine de votre projet Magento.
  2. Installation via modgit :

    modgit add stock-movements https://github.com/jreinke/magento-stock-movements.git

    Exemple complet d’utilisation de modgit ici.

Il ne vous reste plus qu’à vider le cache Magento et c’est tout !

Aperçu

Une fois installée, l’extension ajoute un onglet sur la page de modification d’un produit :

Mouvements de stock

Compatibilité

L’extension a été testée sur les versions de Magento suivantes : 1.5.x, 1.6.x, 1.7.x

44 réponses à “Magento : Enregistrer les mouvements de stock de vos produits”

  1. Web,aster dit :

    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 dit :

    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’);

    $installer->startSetup();

    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’);

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

    And now it works ;)

  3. Dan dit :

    Thanks for the Stock History Extension. Great work! 1.6.2

  4. Vincent Toms dit :

    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 dit :

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

      • Sterling Okura dit :

        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 dit :

        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 dit :

          Hi,

          I tried to install the module on Magento CE 1.3.2.4 (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 1.3.2.4 ?

          Thanks a lot for your help.

  5. Lee dit :

    Looks great but installed on 1.5.1.0 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 dit :

    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?

    Jason

  7. Jorge dit :

    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 dit :

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

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

  8. Rafal dit :

    Magento 1.7.0.2
    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
    Thx

  9. Pete dit :

    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 dit :

    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 dit :

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

  12. Johann Reinke dit :

    Hello,

    The bug has been fixed (multiple/duplicate lines).
    Update the source code from GitHub: https://github.com/jreinke/magento-stock-movements/tree/legacy

  13. Aurélien dit :

    Hello,

    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.

    Regards,

    Aurélien

  14. Timothy dit :

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

    https://github.com/jreinke/magento-stock-movements/issues/13

  15. Ricardo dit :

    Anyone try to install this in magento 1.8?

  16. bbaccessories dit :

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

    • Peter Svegrup dit :

      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?

      @Johann
      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 dit :

    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 dit :

    hu!
    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?

    Dave

  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 dit :

    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.

    Thanks,

  21. Kai-Uwe dit :

    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 dit :

    Hi, does this still work on Magento ver. 1.9.0.1?

  23. Vinicius dit :

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

  24. rlip dit :

    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 dit :

    Thanks a lot. Nice work

  26. JeromeS dit :

    Hi,

    Did anyone try to install this on Magento 1.3.2.4 ? 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.

    Jerome

  27. Elvis Čehaja dit :

    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?

  28. Deepak dit :

    Hi, Is it possible to record stock history when customer pays with PayPal Express.
    Thanks

  29. Kelley dit :

    After I upload this extension to a couple of my magento sites, I get this error.

    SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘shopsorg_wzt5koj.bubble_stock_movement’ doesn’t exist

    Can you help me out? It works wonderfully on all of my other stores. I don’t see why it wouldn’t work on these stores.

  30. George dit :

    Hi, I successfully copied the files and cleared the cache but I’m still getting the old classic Stock History screen in the admin product page.
    I have a new Stock Movements option in the catalog section but not in the product itself. Any thoughts? Many thanks.

  31. Is this compatible with 1.8 magento? This will be very handy for us.

  32. Brian Houdek dit :

    Thanks for creating such an awesome extension! We have had issues with inventory numbers inexplicably changing. This will help us identify the cause. You are THE MAN!

Laisser un commentaire

* Champs requis

Categories