Developer forum

Forum » Ecommerce - Standard features » Need to get product discontinued property per variant

Need to get product discontinued property per variant

Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

In 9.17, I need to get a specific product from the master product + variantoptionid , and then access its Discontinued state.

Any ideas how this may be acheived?

I am currently using call to 

var productService = new Dynamicweb.Ecommerce.Products.ProductService();
var productStatus = productService.GetProductById(productId,variantId,languageId); 

and I have ONE product which is set to discontinued

But it returns FALSE for Discontinued on each product.


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Stephen

Just checked the code - and it seems to be fine on that property.

Are you sure you are on the right variant and not a master or vice versa? Also check if the field is language managed or not under field settings - because then that setting can differ from master to variant or if products are in a family.

Votes for this answer: 1
 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Hi Nicolai. 

I am jumping into the   " foreach (var option in group.Options) "  loop in swift components/variantselector.cshtml and then passing the productId with each variantid in the loop in the hope of getting the specific productid for that master + variantid.

Is this not the correct way to do it?

 

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

I tried to turn off  "Allow changes across languages", but our staging server hung when saving, so gonna have to wait for that to be fixed :(

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

I am probably getting the product id for the one I am on yes. But I cannot find a MasterProperty in the API, or a GetProductParent call in the service. Could you point me in the right direction?

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

I think I may have actually fixed it now though... :)

 

You must be logged in to post in the forum