Developer forum

Forum » PIM » Query showing Products with no Related product

Query showing Products with no Related product

Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hello,

I'm working on a case where the customer want's to see a list of products that should have an accessory connected, but does not have one at this moment.

The idea is the products will have some sort of field that specifies wheter it should have an accessory, like a boolean "Must Have Accessory", and we then query on products that have this set to true, but have no related product in a specific related group "Accessories"

Can I achieve this with standard query's/indexes?

Thanks,

Justin 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Justin

Yes - you should be able to do that.

In the index, add a new field - each relation group exposes a field from the schema called "ProductRelationGroup_*" that contains a list of products related to a given product in a given relation group.

The field can be a string or string array. Then add it to your query to find fields that are empty - using isempty expression.

 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Thanks!

I'm still having some trouble to get this to work. I created the field on the index:

And added it to the query:

But eventhough one of the products (ID 10123) with "Requires Accessoire = true" has no related accessoires, they still show both in the result:

I thought let's try and see what exactly is in the index, but using Luke I cannot find the field RelatedAccessoires in the indexa at all.

Any idea what I might be missing?

Justin

 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Seems I also have some other weird behaviour, when I check the "Requires Accessoire" on a product, the query shows the newly checked product but then shows the "Requires Accessoire" is actually false:

I was thinking maybe caching, but I tried al sort of refreshing and the column keeps showing false..

 

You must be logged in to post in the forum