Create Product Filter with Python API

Hi Forum,

Does anyone know how to create a vcCombinationProductFilter with a series of ExpressionFilters (vcProductFilter) using the Python API?

I can access these filters if I create them through the UI first, but I don’t know how to start from scratch.

Hello,

you will need to use the filter constants:

So first you want to set your combination filter with .setFilter :

combiFilter = statement.setFilter(VC_FILTER_COMBINATION)

then you can insert filters in this filter using these combination operation constants:

with .insertFilter( index, filterType, operation) :

productFilter = combiFilter.insertFilter(-1,VC_FILTER_CONFIGURABLEPRODUCTTYPE, VC_FILTEROPERATION_AND)
propertyFilter = combiFilter.insertFilter(-1,VC_FILTER_PRODUCTPROPERTY, VC_FILTEROPERATION_OR)

you can then define your filters according to the type

1 Like

Thanks, Tilma — It works, thank you very much!

I was trying to figure out where the setFilter method is supposed to be used, but I got completely lost. XD

May I ask: What does vcProductFilterStatement inherit from, and where can we obtain an object of this type?

I think all statements which have a filter are vcProductFilterStatement (TransportIn, StartTransportIn, ReserveProduct, Buffer, GetProducts, …) and all other statements are just vcStatements

1 Like

Got it. Thanks again. :saluting_face: