Developer forum

Forum » Ecommerce - Standard features » Services.Products.GetProductByNumber returns inactive product

Services.Products.GetProductByNumber returns inactive product

Peter Leleulya
Peter Leleulya
Reply

Hi guys,

In a search function I use the GetProductByNumber method.
It works fine, but we now, after many import cycles, have an issue ...

We have multiple product records with the same product number, but only 1 per language which is active.

The GetProductByNumber retuns the first one it encounters, which is an inactive one ....
Shouldn't it return an active product? Or at least give me the option to configure this with an overload?

We don't remove old products but make them inactive for they can be attached to orders.

Do I really have to use GetAllActiveProducts.FirstOrDefault(p => p.ProductNumber == myNumber)?
Sounds like a lot of overhead ...
 

 


Replies

 
Nicolai Pedersen
Reply

Hi Peter

Well, product number is not the key - or part of it, so really it should be returning a collection of products. It should not filter out inactive products in the API here in the service - that happens where the product is rendered or send out in feeds, webapi etc.

You should have a product id that is unique - maybe that can be used?

If we should add a new method to the service, it would be GetProductsByNumber that will return a collection of products that you can then filter on active property.

Which version are you currently on?

BR Nicolai

 
Peter Leleulya
Peter Leleulya
Reply

Hi Nicolai,

I agree that GetProductsByNumber would be the most logical option.

We are currently on All-In-One - Business version 9.10.12

 

You must be logged in to post in the forum