Developer forum

Forum » Ecommerce - Standard features » Product retrieval (query) based on properties of variants

Product retrieval (query) based on properties of variants

Siv Hansen
Siv Hansen
Reply

A client of mine wants to retrieve products in their product list based on criteria in variants. They have this custom field, itemstatus code, which on the product is always empty, but on the variants always has a value.

I've setup a query and can retrieve products if the itemstatus code is on the main product, but cannot seem to target variants. Any clues on how to proceed from here?


Replies

 
Nicolai Pedersen
Reply

Can you show a screen dump of your query?

 
Siv Hansen
Siv Hansen
Reply

 

These are the main product query. On the preorder query, we override some of these:

 

 

I don't know if I've screen dumpet what you need, but if you'd like direct access instead I can email you the URL (hosted@DW)

 
Nicolai Pedersen
Reply

Hi Siv

You also have an expression saying "variant = False" meaning you only query master products that does not have this information.

So you would have to remove that expression.

That would give you all products including variants in the list - that is something you might not want.

So if you only want masters where one if its variants has this ItemStatusCode, you need to aggregate the value of all ItemStatusCode fields from all variants to an array of ItemStatusCodes on the master. The only way that is currently possible is to do a bit of custom code.

Or you can create a custom field "ItemStatusCodeOnVariants" or something like that, as a string, and then create a SQL that will run in a scheduled task (there is a SQL scheduled task) that will find all variant ItemStatusCode values for each master and add the values as a comma seperated value on the master product in the custom field. Then the index can index it as an array and it can be queryed.

A bit technical, but should be feasable - difficult thing is to write the SQL.

BR Nicolai

 

You must be logged in to post in the forum