Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is it possible to update stock from c#? I tried some different stuff, and I get an error when I do it the-umbraco-way.
It's related to this post http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/34364-Optimistic-stock-system
You will need to use the NodeStock class which have a bunch of static methods. It's placed in the TeaCommerce.Data namespace.
Thanks! I works perfect.
Should I use ChangeStock or SetStock? ChangeStock doesn't seems to update the node. SetStock can do it, but does it run an umbraco UpdateDocumentCache?
The thing is that we will have around 200-300 people ordering in the same minute. So I think umbraco will die if the cache is updated 200 times in one minute.
Well. The stock management of Tea Commerce uses a separate custom table in the database. This is partly because of performance which would be very slow if the value was on the node. The other part is that we would have to publish the node, which could potentially publish something the user have previously saved.
Your doc type should use the custom Tea Commerce stock datatype, which will fetch the stock from the custom table. Then it should be displayed properly.
Also you should use the GetStock method to retrieve the value for a specific node.
As to your 2-300 people ordering on the same time, that won't be a problem. It's a simple update to the database each time.
ChangeStock vs SetStockChangeStock will add or withdraw stock from the current stock of the node/product. SetStock will brutally overwrite the stock.Also ChangeStock uses SetStock after calculating the new stock.
Yes, I know about the stock is in the database, and I use the stock datatype on my node.
When I tried ChangeStock, I took the current stock (with GetStock) and took one from that. I can see know thats wrong, and that why I didn't work as I expected.
But every things work perfectly now! Thanks :)
No problem. I'm glad to help. :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted