Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » Error editing EcomGroup after upgrade to 9.4.6

Error editing EcomGroup after upgrade to 9.4.6

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I just started an update of a 8.9.x solution.

First thing I have noticed after upgrade is that I get an error when trying to edit an EcomGroup.

Not sure where to start debugging. I have attached the error.

Thank you,

Adrian

edit_group_error.png

Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

It indicates one of 2 things. You either have salesdiscounts (the old ones) with a provider that no longer exists - maybe a custom one that was not converted?

Or that you have salesdiscounts that includes groups that no longer exists.

I believe it is the first...

BR Nicolai

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Makes total sense.

Thank you,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,
After an extensive set of conversions and resetting and reinstalling, I can now say for sure that the problem is caused by something inside of 9.4.6 (actually, I have also tried 9.4.7 and 9.4.8 with the same outcome).

I have removed all customisations before making the tests. In any 9.4.x branch, I get the above error. Downgrading to 9.3.14 solved the problem.

Now, the question is, how do I upgrade to 9.4?

Thank you,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Any news on this?

Any suggestion?

Thanks,

Adrian

 
Nicolai Pedersen
Reply

Hi Adrian

Sorry, no. I cannot reproduce.

I need a link to the solution.

Sorry about the inconvenience.

BR Nicolai

 
Nicolai Pedersen
Reply

Or the content of the table "EcomSalesDiscount"

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Here is the link to the solution (although it is running 9.3.14 instead of 9.4.x): http://australdev9.dotfusion.ro/

And I have attached a zipcode with EcomDiscount and EcomDiscountTranslations

 
Nicolai Pedersen
Reply

Hi Adrian

Thanks. I think it is your SalesDiscounts - not the EcomDiscount that causes this. I cannot reproduce it...

You have 70-ish salesdiscounts defined - some of them custom. It could be loading one of these discounts that loads differently on DW9 - or that the reference is wrong due to the upgrade from 8-9. Try taking a look at the table - maybe disable them all and see if that removes the exception, and if so, find the one who does.

Or we need a complete copy of the database and custom dll in order to debug.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

In my tests, I have completely removed our custom code. Tried also the "deactivate all discounts" approach before that.

Trying to run with 9.4.x did not work (we got that error) but as soon as I downgraded to 9.3.14, it just worked. Same database, same bin, same files.

There should be something particular about 9.4. Either in how it initiates the Discounts or how it initiates the Edit Groups functionality.

I tried every trick I had, just to make it work in 9.4.x. Everything else seemed to work, except for that EditGroup.

Thanks,

Adrian

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> In my tests, I have completely removed our custom code. Tried also the "deactivate all discounts" approach before that.

That may not be enough when there's, say, a discount provider that references a custom provider. Did you try clearning the discounts from the database? We had a similar issue a while ago upgrading to 9.4 (but we came from 8)

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Imar,

I have not. The reson I have not tried it is that downgrading to 9.3.14 solved it.

Therefore I imagined it is something different in how 9.4 handles GroupEditing.

I can try that approach as well but even if it will work for me, it might still be an issue for other upgrades. I believe this error needs to be catched and solved.

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

I tried also removing the Discounts from the table.
Same result.

I have also upgraded to 9.4.9. Same result.

At a first glance, comparing Group/SalesDiscount related tables between 9.4.x (clean install) and my version, I am missing a few autoID fields:

EcomGroups: GroupAutoId

EcomGroupRelations: GroupRelationsAutoId

EcomGroupProductRelation: GroupProductRelationAutoid

EcomSalesDiscount: SalesDiscountAutoId

EcomSalesDiscountCurrency: SalesDiscountCurrencyAutoId

EcomSalesDiscountLanguage: SalesDiscountLanguageAutoId

I have run updates a few times already without any luck.

Maybe 9.3.x does not have a strong dependency on these AutoID fields?

Thanks,
Adrian

 
Nicolai Pedersen
Reply

Hi Adrian

Those autoids fields are pretty old. They are actually from DW8 and is not part of the update scripts of DW9. But did you upgrade the solution to 8.9.12 or higher before upgrading to 9? That will apply the last required fields.

There is a difference between 9.3 and 9.4 - but it is very limited, see dump.

Anyways - I've tried reproducing it etc. I cannot... So we need a copy to add a debugger or you can download the pdb files and add them to the bin - that would give us better exception descriptions that might help us understand. If you removed the salesdiscounts all together, I do not understand the exception...

BR Nicolai

Capture.PNG
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I have upgraded from 8.8.1.32 to latest 8.9, then I have upgraded to 9.4.2.

I will try the pdb approach.

In the meantime, I see that LoadDiscounts method is different between 9.4 and 9.3.

Here is what I see (using ILSpy):

9.3.14

// Dynamicweb.Admin.eComBackend.EcomGroupEdit
private void LoadDiscounts(Group grp)
{
	EcomGroupEdit._Closure$__307-0 closure$__307- = new EcomGroupEdit._Closure$__307-0(closure$__307-);
	closure$__307-.$VB$Local_grp = grp;
	checked
	{
		if (!base.IsPostBack)
		{
			SalesDiscountCollection salesDiscounts = SalesDiscount.GetSalesDiscounts(Context.Language);
			int num = salesDiscounts.Count - 1;
			for (int i = 0; i <= num; i++)
			{
				SalesDiscount salesDiscount = salesDiscounts[i];
				if (Operators.CompareString(salesDiscount.DiscountType, typeof(ProductDiscount).FullName, false) == 0)
				{
					ProductsAndGroupsHandler productsAndGroupsHandler = new ProductsAndGroupsHandler(salesDiscount.Parameters);
					ListItem listItem = new ListItem(salesDiscount.Name, salesDiscount.Id);
					if (productsAndGroupsHandler.Type == HandlerConfigurationType.All)
					{
						listItem.Selected = true;
					}
					else
					{
						listItem.Selected = (productsAndGroupsHandler.GroupsSelected.Where((closure$__307-.$I0 == null) ? (closure$__307-.$I0 = ((Group g) => Operators.CompareString(g.Id, closure$__307-.$VB$Local_grp.Id, false) == 0)) : closure$__307-.$I0).Count() > 0);
					}
					listItem.Enabled = (salesDiscount.Active && (salesDiscount.IsLocalized || Operators.CompareString(Context.LanguageID, Application.DefaultLanguage.LanguageId, false) == 0));
					this.Discounts.Items.Add(listItem);
				}
			}
			if (this.Discounts.Items.Count == 0)
			{
				this.DiscountsContainer.Visible = false;
			}
		}
	}
}

And this is 9.4

// Dynamicweb.Admin.eComBackend.EcomGroupEdit
private void LoadDiscounts(Group grp)
{
	EcomGroupEdit._Closure$__309-0 closure$__309- = new EcomGroupEdit._Closure$__309-0(closure$__309-);
	closure$__309-.$VB$Local_grp = grp;
	if (!base.IsPostBack)
	{
		IEnumerable discounts = Services.SalesDiscounts.GetDiscounts(Context.Language);
		try
		{
			IEnumerator enumerator = discounts.GetEnumerator();
			while (enumerator.MoveNext())
			{
				SalesDiscount current = enumerator.Current;
				if (typeof(IProductDiscount).IsAssignableFrom(current.GetSalesDiscountProvider().GetType()))
				{
					ProductsAndGroupsHandler productsAndGroupsHandler = new ProductsAndGroupsHandler(current.Parameters);
					ListItem listItem = new ListItem(current.Name, current.Id);
					if (productsAndGroupsHandler.Type == HandlerConfigurationType.All)
					{
						listItem.Selected = true;
					}
					else
					{
						listItem.Selected = (productsAndGroupsHandler.GroupsSelected.Where((closure$__309-.$I0 == null) ? (closure$__309-.$I0 = ((Group g) => Operators.CompareString(g.Id, closure$__309-.$VB$Local_grp.Id, false) == 0)) : closure$__309-.$I0).Count() > 0);
					}
					listItem.Enabled = (current.Active && (current.IsLocalized || Operators.CompareString(Context.LanguageID, Application.DefaultLanguage.LanguageId, false) == 0));
					this.Discounts.Items.Add(listItem);
				}
			}
		}
		finally
		{
			IEnumerator enumerator;
			if (enumerator != null)
			{
				enumerator.Dispose();
			}
		}
		if (this.Discounts.Items.Count == 0)
		{
			this.DiscountsContainer.Visible = false;
		}
	}
}

 

Looks pretty different for me.

I will try the pdb approach and let you know.

Thanks,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Using pdb files gave me this error:

[NullReferenceException: Object reference not set to an instance of an object.]
   Dynamicweb.Admin.eComBackend.EcomGroupEdit.LoadDiscounts(Group grp) in E:\Agent\_work\117\s\01 - Applications\Dynamicweb.Admin\DW94\Dynamicweb.Admin\Admin\Module\eCom_Catalog\dw7\edit\EcomGroup_Edit.aspx.vb:376
   Dynamicweb.Admin.eComBackend.EcomGroupEdit.Page_Load(Object sender, EventArgs e) in E:\Agent\_work\117\s\01 - Applications\Dynamicweb.Admin\DW94\Dynamicweb.Admin\Admin\Module\eCom_Catalog\dw7\edit\EcomGroup_Edit.aspx.vb:282
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

But, I have tried again cleaning up the SalesDiscounts table and after a few recycles I was able to load the EditGroup page correctly.

Which means that the error is somehow related to one of the discounts. Probably one of our own.

I guess the main difference between 9.3 and 9.4 is that in 9.4 you actually try to validate the discounts that apply to the EcomGroup instead of just listing them.

I will investigate further in the SalesDiscount code.

Thank you,

Adrian

 

 

 
Nicolai Pedersen
Reply

Hi Adrian

That last debug info helps me to understand a little better, and indicates that you have salesdiscounts that uses a provider that cannot be initiated.

The difference between 9.3 and 9.4 is 2 things - first we have moved the loading and caching of salesdiscount into a new service layer - behavor is more or less the same. The other change is that salesdiscounts now supports custom ProductDiscounts using the IProductDiscount interface on a salesdiscount. Because of that change, the group edit loads the salesdiscount provider to see if it implements this new interface - earlier it only looked at the name.

So that last change is probably what is causing your issue - it indicates that you have salesdiscounts of types that does not exist or does not load. As I thought in the first reply.

If you delete everything from salesdiscount table I cannot see how you should ever get to the line you mention.

BR Nicolai

 

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

It makes sense and you were right. Deleting everything made it work.

I am sorry I have insisted that much on the subject.

Thank you very much for your patience.

Adrian

 

You must be logged in to post in the forum