Exception when deleting categories

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Exception when deleting categories

Post by kyleS2D » Mon Jul 18, 2016 6:11 am

I am getting an exception when deleting categories. I am using the Red Circled X Delete button on the Browse Catalog page. I don't get in when deleting every category, but is occurring on the majority of them.

The exception is:
An error has occured at https://go.storetodoor.org/Admin/Catalog/Browse.aspx
Exception: Exception of type 'System.Web.HttpUnhandledException' was thrown. Stack Trace: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.GoButton_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.GoButton_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.GoButton_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.GoButton_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Mon Jul 18, 2016 8:33 am

Hello,

What version are you using?

Are there products and/or sub-categories within the category you are trying to delete?

If you get the error, can you refresh or go back to the page and confirm whether the category still exists or if the delete action actually worked?

I'm surprised by the error which makes me think that you have some data integrity issue. Have you tried to add a new category through the interface and then remove it? Let me know if that works.

Thanks
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Mon Jul 18, 2016 9:23 am

What version are you using?
We are using AbleCommerce GoldR9 (build 7670)
Are there products and/or sub-categories within the category you are trying to delete?
There are both products and sub-categories in the categories I am trying to delete. I've also tried deleting the sub-categories first, but that doesn't always work because I get the same error when deleting some of the sub categories as well.

Does a category have to be empty of items before it can be deleted?
If you get the error, can you refresh or go back to the page and confirm whether the category still exists or if the delete action actually worked?
The categories are not being deleted, they are still in the database.
I'm surprised by the error which makes me think that you have some data integrity issue. Have you tried to add a new category through the interface and then remove it? Let me know if that works.
I was afraid of that.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Mon Jul 18, 2016 10:01 am

Well, I am also seeing a problem, but I can't seem to figure out the reason. Like you said, sometimes it works and then sometimes not.

You should be able to delete a top-level category and it will delete everything assigned to it - products and sub-categories. Both of these database objects can have a lot of associations so there may be something that is being overlooked. I am going to have a developer take a look at the issue.

Ref. Bug report AC8-3175

One thing you can try is to select all the products within the category and there is a "Delete Selected" option at the bottom of the grid. That might be a work-around until we can figure out what is happening.

Thanks
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Thu Jul 21, 2016 4:54 am

Thanks, Katie.

Is there away I can view Ref. Bug report AC8-3175 and follow progress on its resolution?

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Thu Jul 21, 2016 6:02 am

The bug report appears to be invalid. I was having another issue with my own test database which had to do with a new feature in Gold R12.

What happens if you go to the Reports > System > Orphaned Items page? Do you see any products listed there?
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Thu Jul 21, 2016 9:47 am

Yes, there are four items listed in the Orphaned Items report.

I think I am starting to understand our issue. We did a an item update using the data import feature where we changed the visibility and category for nearly every item in our store. We also added new categories via the import.

However, it seems like if a category with a similar name already existed, the item was left in the old category and added to the new category. For example, in our original categories we had:

Non Edible Grocery>Paper/Plastic Products>Paper Towels

Via the data import process we changed the hierarchy to:

Household>Paper Towels

However I found that one item is listed under both categories in the admin. Actually one item is listed three times under the old category, all three have the same product ID.

Do you think this could be the cause of the exception when deleting categories?

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Thu Jul 21, 2016 10:52 am

It would certainly seem like it could be a possible cause. You should not have any duplicate Product Id's. Can you delete the extra products one at a time, or do you get the exception again?

Thanks
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Fri Jul 22, 2016 4:12 am

I was able to delete the duplicate items without issue. What I find strange is that even though four items shared the same product ID, I still had to manually delete all three.

Also, can you tell me if this option Update to categories specified in uploaded data in the Data import wizard moves the products to new categories, or leaves them in the old category and adds them to the new category.

What I'm seeing seems to indicate that it's the latter, but I'm not sure if that's the intended behavior.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Fri Jul 22, 2016 4:37 am

The Data import script is only capable of updating existing or inserting new data. It cannot remove existing data, so I don't believe it would be possible to remove the products from old category.
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Fri Jul 22, 2016 5:03 am

Okay. So that means we have many products in two or more categories.

Would that lead to not being able to delete a category if an item in that category was also in another category? I would hope not.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Fri Jul 22, 2016 5:23 am

I just did a quick test.

Created Category Test1
Created Category Test2
Created product A and assigned it to both categories.
Deleted Category Test 1. The product remains under Category Test 2, so only the association was actually removed during the delete process.
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Fri Jul 22, 2016 5:57 am

Yes. I'm actually seeing the same behavior when I'm able to delete categories. I'm still having the issue where some categories simply can't be deleted though.

I can't seem to figure out yet, why some can be deleted and others cannot.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Fri Jul 22, 2016 6:05 am

My guess, is that you have a data integrity issue. You should not have been able to insert multiple product ID's in the database. There should be one unique product ID that can be associated to multiple categories.
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Fri Jul 22, 2016 7:47 am

I'm
Katie wrote:My guess, is that you have a data integrity issue. You should not have been able to insert multiple product ID's in the database. There should be one unique product ID that can be associated to multiple categories.
I think you're right. Is solving those issues something we could use the AbleCommerce paid support packages to solve?

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Fri Jul 22, 2016 9:20 am

Trying to fix this kind of problem would not be covered under our general support packages. We would be willing to attempt fixing the issue with regular paid support time, however, there is no guarantee with something like this. Hard to tell how bad the data is without first reviewing the database. These are time consuming issues, so you could be looking at a considerable expense.

We always recommend that you backup your database before attempting mass data manipulation. Restoring your backup would be my first choice. Finding and removing the duplicate product's may not be a difficult task, but i becomes a lot more complex when you have to cleanup all the other relationships between these invalid product ID's and their references in other tables - and there are many other tables that reference product IDs.

Another option might be to fix the issues as you go. If you find a duplicate product ID, then try to remove it and let the other associations stay as they are. If you later have a problem deleting, say a product coupon for example, then find the association in the database and remove it manually. I know it's not ideal, but it would be far less expensive than trying to sort out data problem.

Thanks
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Fri Jul 29, 2016 4:02 am

We've had our AC developer looking into this issue, and they've discovered:
There is a table called catalog-nodes and it holds references to categories and their sub-categories and products. When you delete a product from a category, it deletes the product but not the record in the catalog nodes table. So you wind up with a blank reference.
Do you know if this is a known issue, and if not can a bug report be opened?

Here is the stack trace I'm getting when I try to delete a category:

Code: Select all

An error has occured at https://go.storetodoor.org/admin/catalog/browse.aspx 
Exception: Exception of type 'System.Web.HttpUnhandledException' was thrown. Stack Trace: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.CGrid_RowCommand(Object sender, GridViewCommandEventArgs e) at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.CGrid_RowCommand(Object sender, GridViewCommandEventArgs e) at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.CGrid_RowCommand(Object sender, GridViewCommandEventArgs e) at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Inner Exception: Exception has been thrown by the target of an invocation. Inner Exception Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at AbleCommerce.Admin.Catalog.Browse.CGrid_RowCommand(Object sender, GridViewCommandEventArgs e) at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Exception when deleting categories

Post by mazhar » Wed Aug 03, 2016 4:33 am

We enforce this delete casecade via code. If you are deleting product using CommerceBuilder API then it will ensure to enforce this delete casecade and automatically remove product from catalog nodes. If you are performing manual delete directly from database then you will have to do it yourself.

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Mon Aug 08, 2016 5:46 am

I'm getting this error when using the Delete button via the Categories admin page, not directly from the database.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Mon Aug 08, 2016 5:51 am

Do you have an older backup of the database? If so, then I would recommend that you use a database comparison tool like Redgate's SQL Data Compare and SQL Compare products. Here is a link to their website. http://www.red-gate.com/products/

I think you can use the trial version at no cost.

Thanks
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

kyleS2D
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Aug 11, 2015 7:43 am

Re: Exception when deleting categories

Post by kyleS2D » Mon Aug 08, 2016 10:23 am

I'm not sure what's going on, but I'll share what our developers have found. What would explain what the developer describes below?
Let’s take category Dairy > Milk Products > Coffee Creamers

In the Database for catalog nodes you have this

Image


Coffee Creamers being category ID 118, and the 67250 is the product CALIFIA FARMS CREAMER VANILLA. There is only one of this product but in the same category (118) you have 5 references.

So, when you delete a product from this category, AC runs this code
Category category = EntityLoader.Load<Category>(categoryId);
int myindex = category.CatalogNodes.IndexOf(item.Id, CatalogNodeType.Product);
if (myindex > -1) category.CatalogNodes.DeleteAt(myindex);

Which basically says, for this product give me the categories that it is in (118) and the from the catalog nodes table, remove the first instance found.

So, it only removes the first reference and then deletes the product. So the other references in the catalog nodes table still remain for this now deleted product, so you get this in the browse.aspx page

Image

And can’t delete the reference anymore because there is no product.

Long story short, you have to many of the same product in the same category (Bad data) and will have too get these removed

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Exception when deleting categories

Post by Katie » Mon Aug 08, 2016 12:30 pm

I have no idea how you have products listed in the catalog without a name. I'm guessing this is a result of something that was done outside of the user interface or via a data update. I've never seen it before, and no clue how to reproduce it.

There is one thing that might help explain how the catalog nodes table is used.

Let's say you have Product A. It is assigned to Cat 1, Cat 2, and Cat 3.
There will be 3 entries in the catalog nodes table to connect the product to each of the 3 categories.

Now, depending on WHERE you delete the product, there is a different behavior.

If you are viewing the categories, and are within Cat 1, then deleting the product here will remove the relationship between the product and Cat 1. If you look at Cat 2 and Cat 3, the product will still be shown there. So, in summary, deleting products (that are assigned to more than one category) within the category tree will only remove the relationship to the category.

If you view the Manage Products page, and delete the product from here, then it will remove it from the database completely, and all relationships to any assigned categories will also be removed.

I can see room for improvement within our interface. If you delete a product from within a category, then it should first warn if the product is assigned to multiple categories, and if true, then we could be asking if you want to remove this association or the product and all associations.

Hope this helps,
Katie
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

Post Reply