Hi, this method
https://doc.dynamicweb.com/api/html/ae7b1578-1f3d-afde-deb1-0df3391b025b.htm have been marked as obselete.
I cant seem to find its replacement. In orderService you have a GetOrders - but thats all orders retrieved.
Does a method exist that does the same?
Developer forum
E-mail notifications
Order.GetOrders Method (String, Boolean) obselete, but no replacement?
Replies
Hi Jan,
The method you refer to takes a SQL string as input - this is not going to be supported in the future. If you want to do SQL calls, you should use Database instead.
You can continue to use the obsolete method for the rest of DW9, though. We won't delete anything (on purpose!) before the next major release.
Hope this helps you move forward with your project? :)
BR
Martin
Hi again,
So, I was asked to look into our plans for supporting sql query customization of order lookup, and I see that we currently don't have any. Or any concrete plans for supporting this functionality in another form.
This means, that I was wrong about my previous post: The obsolete message should be removed, and will be in the next hotfix.
I'll make a note for our programmers about needing an actual alternative for obsoleted methods. I see that our refactoring of Order has not been as unproblematic to use as I hoped for, so I'll try to do a bit of cleanup on the Obsolete messages.
If you have any other concrete examples of thins we claim to be obsolete without being given an alternative or if there is anything else, please let me know.
BR
Martin
Hi Martin,
Perfect. I will look forward to the next hotfix:>
Hi Martin, i was about to ask the same question.
I'm looking a way to rewrite Order.GetOrders because not only is this depricated but also it could be vulnerable to sql injection if not used properly and using parameters to my research.
However we wish sometimes to retreive orders from OrderSecrets, OrderComplete and sometimes also custom variables and sometimes more complex where statements. This method could also be used to write more complex reports.
Retreiving all orders from code, filtering them with a where clause could be a solution, but i rather use database queries to to that work for me because of performance reasons.
Maybe a possible solution would be to allow the GetOrders to allow a Dynamicweb.Data.Database.CreateConnection().CreateCommand or allowing us to access OrderService.ExtractOrder to do it ourselfs. It's quite a hassle converting a SqlCommand to an order yourself.
I've written this down so I can take a look at it later.
Currently, we're trying to limit how to access the database with the following setup:
1 Repository + 1 Service + 1 Model
I believe that this way is a nice, clean approach for most use-cases, but I can see that it might not solve your needs for Orders. I'll have to come up with an alternative for this.
Im currently about to go on my summer vacation, so the response-time is going to be a couple of weeks - but I will get back to you!
BR
Martin
Thanks for your reply! In most cases this interface provides a proper way to retreive most data. One way of achieving this is to provide a query building interfaces to solve such problems. Such as Arel ( https://www.thegreatcodeadventure.com/composable-query-builders-with-arel-in-rails/) for Ruby. They provide an abstract interface to build up your selection using method chaining. At the end they build up the query just before retreiving the data. This allows the user to be very flexible but then again, you will be probably extending the current DynamicWeb ORM too much.
Enjoy your holiday. Thanks for notifying!
Hi,
I am running into some more issues:
I am now using 9.4.16
Before this would work:
string testsize = "XLLL";
//add / update this to variant options
VariantOption optSize = VariantOption.Create(testsize);
optSize.Id = testsize;
optSize.Name = testsize;
optSize.GroupId = "Size";
optSize.LanguageId = "LANG1";
optSize.Save(testsize);
This gives me an unhandled error now. But only if the testsize does not exist it seems.
I also tried using the VariantOptionService. Same issue.
Let me know if this is me or some error in the code.
On a sidenote. The VariantOptionService does not provide a way to Create? And the Create used now is deprecated.
Hi Jan
Can you please post the exception?
Thanks, Nicolai
Hi Nicolai,
Yes here it is:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Dynamicweb.Ecommerce
StackTrace:
at Dynamicweb.Ecommerce.Variants.VariantOptionRepository.Save(VariantOption variantOption)
at Dynamicweb.Ecommerce.VariantOptionService.Save(VariantOption variantOption)
at Dynamicweb.Ecommerce.Variants.VariantOption.Save(String id)
....
at Dynamicweb.Scheduling.AddInJob.Execute()
Bump on this one. Am I the only one who get this error?
Hi Jan,
You should be using it like this:
VariantOption optSize = VariantOption.Create(id);
optSize.Id = id;
"id" is normally VO# - the reason why this particular method is obsolete, is because of how difficult it is to "guess" the correct id to provide. When you create a new VariantOption like this you always need to provide the empty string as an id. That's just how it's been working before.
So.
string id = "";
VariantOption optSize = VariantOption.Create(id);
optSize.Id = id;
...
Hope this helps you complete the code.
BR
Martin
Hi Martin,
Before I added the ID in create (not empty) and the same in optSize.id and again the same in Save - as you can see from example above.
What should I do now if I need to mimic this? before this was smehow handled by your logic. Should I do anything differently?
VariantOption ids are expected to be called "VO#" - that's just the way they where made long ago. :(
If you changed exactly the lines of code as I showed you, things should work.
string testsize = "XLLL";
string id = "";
//add / update this to variant options
VariantOption optSize = VariantOption.Create(id);
optSize.Id = id;
optSize.Name = testsize;
optSize.GroupId = "Size";
optSize.LanguageId = "LANG1";
optSize.Save(); (optSze.Save(id); never did what I think you believed it should do...)
I dont think we had alot of people who needed to create variantoptions dynamically before - most of the things that are related to variants, seem to be about VariantCombinations (the actual variant of a product such a Product = T-Shirt, VariantId="VO1.V10" where VO1 = Small and VO2 = Green. So, Small+Green T-Shirt).
Did this work for you?
BR
Martin
Hi Martin, yes now it works for me. Although I did not send an empty "optSize.Id = id;"
TY:>
You must be logged in to post in the forum