Developer forum

Forum » Ecommerce - Standard features » RelatedGroupViewModel.GetRelatedProducts() is returning in-active products

RelatedGroupViewModel.GetRelatedProducts() is returning in-active products

Jesper Holm Damgaard GetRelatedProducts()
Reply

Hi guys

When i call ProductViewModel.RalatedGroups.GetRelatedProducts() i get all related products. This is all good.

Now i check this setting in the backend:
 

 

Now I would expect to get all active products, but i dont. I still get all related products including in-active ones.

I can easily work around this in my template, but I rather not, and have it working based on the settings from the backend.

Is this a bug or am I doing somthing wrong?

--
All the best,
Jesper


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

It is feature. The settings do not affect output based on a query, please see details. So, they can be applied on rendering output of regular (old) product catalog has source e.g. 'Product groups' correctly.

BR, Oleg QA

 
Jesper Holm Damgaard RelatedGroupViewModel
Reply

There is no problem with the products i get from the query, they are filtered by expressions on the query.

The problem is when i call GetRelatedProducts on those products, it returns all products, including in-active ones. As far as I can see, this is an extension method on RelatedGroupViewModel which has no connection to the query. 

That means i have to filter the result from GetRelatedProducts before using it in my template:

foreach (ProductViewModel productViewModel in productsFromQuery )
{
  foreach ( RelatedGroupViewModel relatedGroup in productViewModel.RelatedGroups )
  {
    IEnumerable< ProductViewModel > relatedProducts = relatedGroup.GetRelatedProducts();
    IEnumerable< ProductViewModel > onlyActiveRelatedProducts = relatedProducts.Where( rp => rp.Active == true );
  }
}
 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

I was able to reproduce the issue using appropriate dwapi request as well. New task 6933 has been created to recearch and fix it. Thanks for finding.

BR, Oleg QA

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply
This post has been marked as an answer

Hi Jesper

The problem #6933 regarding RelatedGroupViewModel.GetRelatedProducts() is returning in-active products

Has now been fixed in Dynamicweb version 9.13.3
Get this from the download section https://doc.dynamicweb.com/downloads/dynamicweb-9

Sorry for any inconveniences

Kind Regards
Dynamicweb Support
Kristian Kirkholt

Votes for this answer: 1

 

You must be logged in to post in the forum