Hello,
I have a BatchIntegrationScheduledTaskAddin for update product data from a ERP.
This addin row all the products using de ProductService class, for every product i ask to the ERP the information about this product,
Once i get the data from the ERP i update the customFields of the product in my DynamicwebDatabase.
The problem is that my script only update a random set of articles and i dont know why.
Here is the code:
CemevisaERPConection cemevisaERPConnection = new CemevisaERPConection();
ProductService productService = new ProductService();
//search all products
foreach (var p in productService.GetActiveProducts("LANG1", true))
{
//doesnt have ERP id
if(string.IsNullOrEmpty(p.Number))
{
continue;
}
//ask ERP for info
var resultadosERP = cemevisaERPConnection.getArticleInfoById(articlesWebServiceURI, p.Number).Cast<CemevisaArticle>();
foreach (var article in resultadosERP)
{
productService.SetProductFieldValue(p, "Clasificacion", article.classification.Code);
productService.SetProductFieldValue(p, "Clase", article.Class.Code);
productService.SetProductFieldValue(p, "identificador_subfamilia_erp", article.aux2.Code);
productService.SetProductFieldValue(p, "descripcion_subfamilia_erp", article.aux2.Description);
productService.SetProductFieldValue(p, "identificador_familia_erp", article.aux6.Code);
productService.SetProductFieldValue(p, "descripcion_familia_erp", article.aux6.Description);
productService.Save(p);
}
}
//rebuild product repository
BuildProductIndex();
return true;
}
Thanks ,
Jose