Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    Dec 14, 2011 @ 17:23
    Matt Taylor
    0

    TeaCommerce.Base.GetStock - Nullable object must have a value

    I'm getting an error when calling the TeaCommerce.Base.GetStock for a product node that has not had its stock level set.

    Of course the stock level should be set mandatory when creating a product but there exists a whole bunch of products where it is not been because until now the stock functionality was not in place.

    It would be nice if it could perhaps return 0 for these products rather than an error.

    I'm using an older version of Tea Commerce so maybe it has already been addressed?

  • Anders Burla 2560 posts 8256 karma points
    Dec 15, 2011 @ 11:23
    Anders Burla
    0

    Hi Matt

    Which Tea Commerce version do you run at the moment? Could you try and update and see if the problem is still there? If the problem is still around could you try and send me a screen of your document type you use as a product and then a screen of one of the products data that is causing problems. Is it because the umbraco node doesnt have the stock property because it was created before you added the stock peoperty to your document type?

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Dec 15, 2011 @ 15:38
    Matt Taylor
    0

    Hey Anders,

    It's V1.4.1.0 BETA.

    I'll do an upgrade and play around and get back to you.

    Cheers,

    Matt

  • Anders Burla 2560 posts 8256 karma points
    Dec 15, 2011 @ 15:50
    Anders Burla
    0

    Great - looking forward to hear from you again

    Kind regads
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Dec 15, 2011 @ 18:41
    Matt Taylor
    0

    Hi Anders,

     

    V1.4.1.2 is now in place and the error still occurs.
    Yes basically the stock property has been in place since the beginning but it wasn't being used in any way so it was set 'optional' and never populated by any editors.
    Below is the data for Node 1640.
    I'm now adding new functionality that takes into account product stock levels, but of course there are lots of existing products where no value has ever been entered.
    As you can see below, there is no record for NodeId 1640 in the Stock table and I beleive this is the problem.
    I think the GetStock method just needs to handle this.
    My initial thought was that it could return a stock level of 0. Some developers however might like it to error if you pass the node ID of a non-product item which of course wouldn't have stock.
    Regards,
    Matt
  • Anders Burla 2560 posts 8256 karma points
    Dec 16, 2011 @ 12:15
    Anders Burla
    0

    Hi Matt

    We will try and have a look at doing a solution for this method - because it shouldnt just give you an error :)

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Dec 16, 2011 @ 13:16
    Matt Taylor
    0

    Thanks, one of those odd cases that shouldn't happen but can.

    I can easily work around it for now.

    At least I finally upgraded to the latest version. :-)

     

  • Rune Grønkjær 1372 posts 3103 karma points
    Dec 19, 2011 @ 08:46
    Rune Grønkjær
    0

    Hi Matt,

    I don't understand how it fails. The standard starter kit for Tea Commerce uses GetStock, and no errors are thrown. Almost none of the products in the starter kit have a stock entered, so they should all throw the error.

    A quick glance in the code reveals that GetStock will return an empty string if no stock is found, for the requested node. It might throw an error if GetStock recieves an empty node, or something like that. Please check what param you are sending to GetStock and maybe do an ?umbDebugShowTrace=true, to reveal the error.

    /Rune

  • Matt Taylor 873 posts 2086 karma points
    Dec 19, 2011 @ 10:20
    Matt Taylor
    0

    OK Rune, I'll look into what's happening a bit more.

  • Rune Grønkjær 1372 posts 3103 karma points
    Dec 19, 2011 @ 10:23
    Rune Grønkjær
    0

    Yeah, I will be ready to help when you have some more info.

    /Rune

  • Matt Taylor 873 posts 2086 karma points
    Dec 20, 2011 @ 12:12
    Matt Taylor
    0

    Hi Rune,

    I know the starter kit uses all XSLT where I'm using all .Net controls. Maybe the error is being ignored in the XSLT? Just a thought.

    If I call TeaCommerce.Base.GetStock(123) and node 123 has not had its stock property set I get the following error.

    System.InvalidOperationException was unhandled
      Message=Nullable object must have a value.
      Source=mscorlib
      StackTrace:
           at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
           at System.Nullable`1.get_Value()
           at TeaCommerce.Base.GetStock(Int32 nodeId)
      InnerException:

    If I set the stock property to say 100 and publish it works fine.

    If I then clear/blank the stock property and publish it errors again.

  • Rune Grønkjær 1372 posts 3103 karma points
    Dec 20, 2011 @ 12:39
    Rune Grønkjær
    0

    We found the error now. We where looking in the wrong place :)

    We will be back with a fix, as soon as posible. Tomorrow at the latest.

    /Rune

  • Matt Taylor 873 posts 2086 karma points
    Dec 20, 2011 @ 14:24
    Matt Taylor
    0

    No worries.

    Cheers Rune.

  • Rune Grønkjær 1372 posts 3103 karma points
    Dec 21, 2011 @ 08:15
    Rune Grønkjær
    0

    Hi Matt,

    I have uploaded a new beta package. Check it out, and see if it works as supposed to.

    /Rune

  • Anders Burla 2560 posts 8256 karma points
    Dec 21, 2011 @ 17:19
    Anders Burla
    0

    Hi Matt

    Tried the new Beta and did it solve your problem?

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Dec 21, 2011 @ 17:28
    Matt Taylor
    0

    Hi Anders/Rune,

    I've not had a chance to try it yet. I will do when I get a moment. I've no doubt it will work. :)

  • Matt Taylor 873 posts 2086 karma points
    Dec 24, 2011 @ 14:21
    Matt Taylor
    0

    This has been fixed in the beta, thanks.

Please Sign in or register to post replies

Write your reply to:

Draft