Developer forum

Forum » Development » Error saving product in custom import module

Error saving product in custom import module

Thomas Larsen
Reply

Upgrading from  8.6.0.4 to 8.7.2.1 has generated an error in a custom import module, when saving a product

Dynamicweb.eCommerce.Products.Product MainProduct = Product.GetProductByID(ProductID, "", "LANG1");
if (MainProduct == null || String.IsNullOrEmpty(MainProduct.ID))
{
   MainProduct.Save();
}

The save method throws the following exception  

   ved Dynamicweb.Extensibility.DataItemListenerService.OnDataItemModified(String category, DataItemModificationsInfo info)

   ved Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String ProductID, String ProductVariantID, String ProductLanguageID, Boolean skipExtendedSave)

   ved Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String ProductID, String ProductVariantID, String ProductLanguageID)

   ved Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String productID, String productVariantID)

   ved Dynamicweb.eCommerce.Products.Product.Save(String productID, String productVariantID)

   ved Dynamicweb.eCommerce.Products.Product.Save()

 

Anybody?

 /Thomas


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Thomas,

Could you post the whole exception? Your post only contains the stack trace, or a part of it, making it hard to determine where the exception originated.

Also, that if-block seems a bit dangerous. Checking whether an object is null and using it even if it is.

- Jeppe

 
Thomas Larsen
Reply

Hi Jeppe,

Thanks for your reply.

The code was just an example (a really bad one). It would of course look like

Dynamicweb.eCommerce.Products.Product MainProduct = Product.GetProductByID(ProductID, "", "LANG1"); 
  
if (MainProduct == null || String.IsNullOrEmpty(MainProduct.ID)) {    
    throw new Exception("ProductNotFound", new Exception(ProductID));
}

MainProduct.Save();

The exception
 System.NullReferenceException: Objektreferencen er ikke indstillet til en forekomst af et objekt.
   ved Dynamicweb.Extensibility.DataItemListenerService.OnDataItemModified(String category, DataItemModificationsInfo info)
   ved Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String ProductID, String ProductVariantID, String ProductLanguageID, Boolean skipExtendedSave)
   ved Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String ProductID, String ProductVariantID, String ProductLanguageID)
   ved Dynamicweb.eCommerce.Products.Product.SaveAndConfirm(String productID, String productVariantID)
   ved Dynamicweb.eCommerce.Products.Product.Save(String productID, String productVariantID)
   ved Dynamicweb.eCommerce.Products.Product.Save()
   ved Firstweb.CustomModules.CustomModules.BOMProductImport.DataImport.DoImport() i c:\Dynamicweb\git\firstweb.customer.solution\custommodules\BOMProductImport\DataImport.cs:linje 213
   ved Firstweb.CustomModules.CustomModules.BOMProductImport.Main.ImportFilesInFolder(String file) i c:\Dynamicweb\git\firstweb.customer.solution\custommodules\BOMProductImport\Main.aspx.cs:linje 95
   

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

This seems to indicate that something is wrong with the setup of the old Products index. Could you post a link to the site so I can check? If you don't want to post the link here, you can send it to me directly here: jea@dynamicweb.dk

Also, if you could copy the debug symbols to the bin-folder and reproduce the error. That way I can see which line fails. You can download them here: http://developer.dynamicweb.com/downloads/debugging-symbols.aspx

Votes for this answer: 1
 
Thomas Larsen
Reply

Sorry my mistake, a reference to an old version of the Dynamicweb.dll in my VS project, was teasing me

 

You must be logged in to post in the forum