Developer forum

Forum » Ecommerce - Standard features » ProductService issues

ProductService issues

Hans Kloppenborg
Reply

Hello,

We wanted to develop some custom code that retrieves a list of products from product-ids, filtered on the current users assortment.

To implement this we tried using the ProductService.GetProductById and ProductService.GetByProductIDs with the "useAssortments" flag on true, but both functions seem to ignore the assortment and give back any product you request.

To hack around this we tried to use ProductService.GetActiveProducts with the  "useAssortments" flag on true, but this function plain crashes with an SQL error.

Final solution was to use the GetAllProducts call with the  "useAssortments" flag on true, this one works AND filters on the assortment of the current user. Then we next filter our list of productIds with a check if they exist in the result of the GetAllProducts call. 

Could you look into the GetProductById, GetByProductIDs and GetActiveProducts api functions and fix them.

Greets Hans


Replies

 
Nicolai Pedersen
Reply

Hi Hans

You also have to set doRefactoring=true on your calls.

If you have encountered an exception, please provide the code you executed and the exception you got. Then I can get someone to fix it instead of guessing :-).

Thanks, Nicolai

 
Hans Kloppenborg
Reply

Hi Nicolai,

See attachment for sample code and exception details.

In event viewer I get the following query details:

--Command text could not be parsed and may cause syntax errors.
SELECT @p0 p.*  FROM EcomProducts p  WHERE ProductActive = 1  AND ProductLanguageID = '@p1'  AND (  (ISNULL( EcomProducts.ProductPeriodId, '' ) = '')  OR (  EcomProducts.ProductPeriodId IN (  SELECT EcomPeriods.PeriodID FROM EcomPeriods  WHERE (  (COALESCE( EcomPeriods.PeriodShowProductsAfterExpiration, 0 ) = 1)  OR (  (COALESCE( EcomPeriods.PeriodActive, 1 ) = 1 )  AND (  (COALESCE( EcomPeriods.PeriodAlways, 0 ) = 1)  OR (  (COALESCE( EcomPeriods.PeriodEndDate, @p2 ) >= @p2)  AND ( COALESCE( EcomPeriods.PeriodStartDate, @p2 ) <= @p2 ) )  )  )  )  AND ( EcomPeriods.PeriodHidden IN ( 1, @p3 ) ) )  )  )  AND (ISNULL(EcomProducts.ProductHidden, 0) <> @p3) 

It seems there is a strange @p0 in the SELECT without a comma seperating it from the p.* making the query invalid.

The call productService.GetProductById(productId, ""true) does not have a refactoring flag, so how do we get that one to work?

The refactoring flag on true for GetByProductIDs makes it work indeed, is there ever a reason to not set that flag on true then? What does it do? And same question really for the bulkfill parameter.

Greetings Hans

devenv_2018-08-17_09-02-22.png
 
Martin Moen
Reply

Old question, but we have the same issue. Is it still not fixed?

Even when using Dynamicweb.Ecommerce.Services.Products.GetProductById it does not take assortments into consideration with useAssortments set to true.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Can you share some of your code and what exception you receive?

 

You must be logged in to post in the forum