Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter 27 posts 192 karma points
    Sep 28, 2017 @ 06:11
    Peter
    0

    Problem persisting inventory stock and low count

    Hello,

    I am experiencing a weird problem with stock and low count. When I create a new product (fill out name, sku and content type) and press 'save', the product is created in the database with stock 0 and low count 0.

    This is fine as I have not edited the product yet. Now as I fill out the details of the product and specify stock and low count and save the product, it appears to be working fine at first, but if I inspect the database, stock and low count are still 0.

    I can refresh the browser and even access the same product from a different browser, and still see the stock and low count which I entered, but the database still says 0.

    I guess this means that the request cache of Merchello is misbehaving? It means that if I restart the website and access the product in Merchello, the data will be read directly from the database and hence show the 'correct' values, which are 0. At this point if I update the stock and low count, the values are correctly saved to the database.

    I can consistantly reproduce this problem, however it does not appear with product variants, only 'normal' products.

    The way which I am currently dealing with this problem is by creating all the products I need, then restart the website, and last filling out stock and low count for all those products. Far from ideal, I'm afraid.

    Can anyone make any sense of this?

    BR. Peter


    Edit:

    Umbraco 7.5.12

    Merchello 2.5.0

  • Peter 27 posts 192 karma points
    Oct 03, 2017 @ 06:50
    Peter
    0

    Ok so I encountered the same problem (it seems) but in a different scenario, namely in the task that removes items from inventory on shipment.

    I recorded a clip showing the problem in Merchello 2.5.0 using FastTrack (this is the source code you download)

    https://www.screencast.com/t/lQ9XIvMFP

    Can someone make sense of this?

    BR Peter


    Edit:

    I just downloaded the Merchello 2.6.0 source code and repeated the experiment as above - exactly the same result regarding stock :-/

  • Peter 27 posts 192 karma points
    Nov 03, 2017 @ 12:17
    Peter
    0

    I have managed to solve the caching issues mentioned above. I modified a number of files in the source code, built a dll and used it in my solution.

    The general issue was regarding clearing the runtime cache whenever the product changes.

    The situations where I would encounter this caching problem are the following:

    1. A product is bought, causing the stock to change - the stock of the product is then later changed through the backend - a product is once again bought, causing the stock to change (but this time compared to the old, cached value)

    2. An order is refunded causing the stock to change (custom code), as the items are put back into stock - a product is afterwards bought, causing the stock to change (but compared to the old, cached value)

    3. A product is created and the stock is immediately changed. The application pool is restarted and the stock is now 0 (the initial value when creating the product)

    My code changes will fix the caching issues in all of these situations. I will create a pull request with my changes and link it here, once I have done so.

    BR. Peter

  • Dan 1274 posts 3885 karma points c-trib
    Jul 09, 2018 @ 14:37
    Dan
    0

    Hi Peter, did you manage to do the pull request? I'm having issues with stock levels in Merchello so will almost certainly face the same caching problems once I've hacked together a fix for the stock level issue by updating the database independently.

  • Peter 27 posts 192 karma points
    Jul 10, 2018 @ 10:59
    Peter
    1

    Hello Dan,

    I completely forgot about this pull request :]

    I will get on it as soon as I can find some spare time :)

  • Dan 1274 posts 3885 karma points c-trib
    Jul 10, 2018 @ 12:57
    Dan
    0

    Thanks, that'd be great. In my instance I'm manually updating the inventory stock level post-transaction as there's a bug in doing this automatically if you sell non-physical products. It's working in that the stock level in the database and the Merchello back-office now reduces correctly upon purchase, but the products on the front-end are pulled from a cache so they're still available to order even when the stock level is zero. Saving the zero-level product through the Merchello back-office flushes the cache.

    So the little piece of the puzzle I'm missing is how to clear the product cache programatically, as I could then run that when I do the db update.

    If you have any pointers on how this might be done it'd be mega helpful.

    Thanks :)

    EDIT, I've tried forcing deletion of the Examine product index:

    ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"].RebuildIndex();
    

    …but this doesn't seem to cause the front-end to recognise the updated stock level.

  • Peter 27 posts 192 karma points
    Jul 16, 2018 @ 07:04
    Peter
    0

    I remember fiddling around with the ItemCacheService in the ProductService.Saved and ProductVariantService.Saved events, but for my specific problem I was unsuccessful in achieving anything useful here. Might be different in your case though.

    As you can see from my pull request, I had to change some internal code, which is why I had to compile a new set of merchello dlls. I am not sure about what can be done cachingwise using the available services.

    As a last resort I guess you could look at what actually happens once you click the save button from the backoffice (ie. which endpoint in merchello is called from via angular)..I donno..I'm hardly an expert on the subject xD

  • Peter 27 posts 192 karma points
    Jul 13, 2018 @ 12:50
    Peter
    1

    Right...so I have submitted a pull request: https://github.com/Merchello/Merchello/pull/2173

    As I write in my pull request comment, I am fully aware that the code changes fixing my specific problem may not be implemented correctly (even though it works)

Please Sign in or register to post replies

Write your reply to:

Draft