Developer forum

Forum » Development » ProductsService

ProductsService

Andrejs Zavorotnijs
Reply

Hi

Have some development tasks and find out that ProductsService class methods throw System.ArgumentNullException

example from custom scheduled task

https://doc.dynamicweb.com/api/html/d4c0db51-a485-d6de-2e52-32c457ebb49b.htm

ProductServices, same issue with other methods
    GetAllProducts <= obsolete
    GetAllProductsByShopId
    GetAllProductsWithoutVariants
    GetProductsByShopId
    GetActiveProducts
    GetCountOfAllProductsWithoutVariants
    GetLastActiveProducts

Find same issue for Dynamicweb.Ecommerce.Services.Products

In Templates same methods executed normally

version 9.13.11

Swift 1.12

 


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Hi Andrejs,

We currently have some context issues in ProductService which we are trying to work out. It's not an easy fix, but we will try to find a solution.
In the meantime you can try to call the service methods with doRefactoring = false and useAssortments = false.

Example:

bool doRefactoring = false;
string productLanguageId = Services.Languages.GetDefaultLanguageId();
bool useAssortments = false;
var products = Services.Products.GetAllProductsWithoutVariants(doRefactoring, productLanguageId, useAssortments);

Alternatively you can try to make updates directly in the EcomProducts table by executing sql statements using Database.ExecuteNonQuery(sql) and then call Services.Products.ClearCache() when you are done. 

Best regards,
Morten

 

You must be logged in to post in the forum