Hi DW,
I've updated my developer solution to 19.2.3.5 and now i can't save product catogories.
I get this error:
IComparer (eller de IComparable-metoder, den afhænger af) returnerede ikke nul, da Array.Sort kaldte x. CompareTo(x). x: '' x's type: 'FieldOption' IComparer: 'Dynamicweb.eCommerce.Products.Categories.Field+FieldOptionSort'.
My code worked before the update, did something change?
See my code in next reply.
Regards
Martin
Developer forum
E-mail notifications
When saving product categories my code fails.
Martin Nielsen
Posted on 20/06/2011 15:18:34
Replies
Martin Nielsen
Posted on 20/06/2011 15:18:51
// Create product category if it doesn't exist Dynamicweb.eCommerce.Products.Categories.Category productCategory = Dynamicweb.eCommerce.Products.Categories.Category.GetCategoryByID( App.CodeSettings.ProductCategoriesCategoryID_SimpleProduct ); if ( productCategory == null || productCategory.Name.Length == 0 ) { productCategory = Dynamicweb.eCommerce.Products.Categories.Category.Create( App.CodeSettings.ProductCategoriesCategoryID_SimpleProduct, "Products" ); productCategory.Save(); } FieldOptionCollection options = new FieldOptionCollection(); foreach ( AnveldelseTXT item in list ) { if ( item.SprogKode.ToLower() == App.CodeSettings.DefaultLanguage ) { FieldOption opt = new FieldOption(); opt.Name = item.AnvendelseNavn; opt.Value = item.AnvendelseKode; opt.IsDefault = false; opt.Sort = i; options.Add( opt ); i++; } } /* Find field in category */ bool foundFilter = false; foreach ( Dynamicweb.eCommerce.Products.Categories.Field f in productCategory.Fields ) { if ( f.ID.Equals( "MyFieldID" ) ) { f.FieldOptions.Clear(); foreach ( FieldOption item in options ) { f.FieldOptions.Add( item ); } foundFilter = true; break; } } // If we didn't find field, create it if ( !foundFilter ) { // Create Field for colors FieldType type = new FieldType( 15 ); productCategory.AddField( App.CodeSettings.ProductCategoriesFieldID_Use, "Anvendelse", App.CodeSettings.ProductCategoriesFieldID_Use, type.ID.ToString(), string.Empty, FieldListPresentationType.CheckBoxList, options ); } productCategory.Save();
Martin Nielsen
Posted on 20/06/2011 15:23:24
The error occurs at line 49.
Jeppe Eriksson Agger
Posted on 20/06/2011 16:59:53
This post has been marked as an answer
Hi Martin,
It seems that a bug was introduced with the addition of Product Category language versioning. It will be fixed in the next hotfix.
As a temporary workaround you can do this before you save:
option.ID = string.Format("{0}{1}Option{2}", categoryID, fieldID, sortIndex);
Hope this helps :)
- Jeppe
Votes for this answer: 0
Martin Nielsen
Posted on 20/06/2011 22:16:59
Hi Jeppe,
Thx, that did the trick.
Looking forward to the hotfix.
Regards
Martin
Martin Nielsen
Posted on 22/06/2011 09:35:00
Hi Jeppe,
I've run into a problem after using your suggestion.
In the Management center, when i go to to Search filter, and click on one of my filtes i get this error:
Message: Elementet er allerede blevet tilføjet. Nøgle i ordbog: 'CF_[ProductCategory1][PFC_USE]' Nøgle, der bliver tilføjet: 'CF_[ProductCategory1][PFC_USE]'
StackTrace: ved System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) ved Dynamicweb.Searching.Specialized.eCommerce.ProductFieldsFilterProvider.GetOptions(String name) ved Dynamicweb.Extensibility.Editors.GroupedDropDownParameterEditor.Render(ConfigurableAddIn AddIn, String Name, Object Value, Hashtable options, String Label) ved Dynamicweb.Extensibility.Editors.GroupedDropDownParameterEditor.Render(ConfigurableAddIn AddIn, String Name, Object Value, Hashtable options) ved Dynamicweb.Extensibility.AddInConfigurator.Render(HtmlTextWriter output) ved Dynamicweb.Admin.EcomConfigurableAddin_GetParameters.Page_Load(Object sender, EventArgs e)
Source: mscorlib
I'm not sure if its the option Id's or the the release, but something is wrong :-(
Got any ideas how to fix this one?
- Martin
I've run into a problem after using your suggestion.
In the Management center, when i go to to Search filter, and click on one of my filtes i get this error:
Message: Elementet er allerede blevet tilføjet. Nøgle i ordbog: 'CF_[ProductCategory1][PFC_USE]' Nøgle, der bliver tilføjet: 'CF_[ProductCategory1][PFC_USE]'
StackTrace: ved System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) ved Dynamicweb.Searching.Specialized.eCommerce.ProductFieldsFilterProvider.GetOptions(String name) ved Dynamicweb.Extensibility.Editors.GroupedDropDownParameterEditor.Render(ConfigurableAddIn AddIn, String Name, Object Value, Hashtable options, String Label) ved Dynamicweb.Extensibility.Editors.GroupedDropDownParameterEditor.Render(ConfigurableAddIn AddIn, String Name, Object Value, Hashtable options) ved Dynamicweb.Extensibility.AddInConfigurator.Render(HtmlTextWriter output) ved Dynamicweb.Admin.EcomConfigurableAddin_GetParameters.Page_Load(Object sender, EventArgs e)
Source: mscorlib
I'm not sure if its the option Id's or the the release, but something is wrong :-(
Got any ideas how to fix this one?
- Martin
Martin Nielsen
Posted on 22/06/2011 09:43:06
Created a seperate post for my last question.
See http://developer.dynamicweb-cms.com/forum.aspx?ThreadID=26530
See http://developer.dynamicweb-cms.com/forum.aspx?ThreadID=26530
You must be logged in to post in the forum