Copied to clipboard

Flag this post as spam?

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

  • Michael Perry 11 posts 43 karma points
    Apr 02, 2016 @ 20:39
    Michael Perry

    Tea Commerce Get Stock returning null on 2nd+ page load

    I am seeing some weird behavior on a new Tea Commerce install. We are using the Razor API Get Stock method. When I publish a product node, the Get Stock call returns the proper quantity as expected, but on every subsequent page load after the first, the Get Stock call returns null.

    This is only occurring on our production environment following the initial deploy to that environment, and we are unable to replicate on any of our other environments (local, stage, UAT). We have a total of four environments (all on Azure) but the production environment is on a separate account owned by the client.

    The following is the code I am using to pull in the quantity on the product detail page.

    qty = TeaCommerce.Api.Web.TeaCommerceHelper.GetStock(Convert.ToInt64(storeId), CurrentPage.Id.ToString());

    Again, this seems to work properly only once after the prodcut is published, but for subsequent page loads this returns null. Republishing the product will get it working again for a single page load.

    I have verified in the DB in the TeaCommerce_Stock table that the quantity always properly reflects the actual product quantity even when the Razor API returns null. Has anyone seen this behavior before or have any ideas on how to troubleshoot?

    Thanks in advance!

  • Anders Burla Johansen 2560 posts 8256 karma points
    Apr 04, 2016 @ 06:47
    Anders Burla Johansen

    Hi Michael

    Doesn't sound anything like a thing we have hear before. As the code returns the right thing the first time and when the product is published, it sounds like a caching problem somehow. We don't cache stock levels in Tea Commerce so be sure to check that the parameter values you send to GetStock is the same all the time.

    Kind regards


  • Michael Perry 11 posts 43 karma points
    Apr 04, 2016 @ 15:02
    Michael Perry


    Thank you so much for your insight. Following your advice, I was able to determine that on the 2nd+ page load the product ID that was getting passed to the GetStock method was incorrect. Further investigation revealed that we had duplicate product nodes for some products, which we believe were created as part of a Courier deploy.

    Once we removed the duplicate products, we are no longer experiencing any issue with pulling the correct quantity. Thank you so much for pointing me in the right direction.

Please Sign in or register to post replies

Write your reply to: