Developer forum

Forum » Development » Product Copy throws exception

Product Copy throws exception

Tom Kamphuis
Reply

Hi Guys,

I'm trying to make a copy of my webshop while using the API. At the moment I'm stuck on an exception which is thrown when calling the Product.Clone() method. Apparently the ProductVatGroupCollection object isn't marked as Serializable in version 8.6.1.6 of DW, which is the case when I look at the class using a decompiler:

using System.Collections.ObjectModel;
namespace Dynamicweb.eCommerce.Products
{
  /// <summary>
  /// A collection of <see cref="T:Dynamicweb.eCommerce.Products.ProductVatGroup"/>
  /// </summary>
  public class ProductVatGroupCollection : Collection<ProductVatGroup>
  {
  }
}

Could you please fix this asap? I'm a little reluctant to copy all properties myself... or is there a workaround?

Cheers!
Tom


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Hi Tom,

You may want to look at AutoMapper which could help in creating copies of objects.

Imar

Votes for this answer: 1
 
Tom Kamphuis
Reply

Hi Imar,

Thanks, works like a charm!

Cheers,
Tom

 

You must be logged in to post in the forum