Can I filter a product lookup by a PX attribute in Groovy?

Question

Is it possible to filter a product lookup by a PX attribute in Groovy like we can in the UI filters? Something like: api.find("P", Filter.equal("PX.ProductPlant.attribute1", plant))?

Answer

Yes, it is: Filter.equal(PXNAME__PXCOLUMN, value)

Example

import groovy.transform.Field @Field final String PRODUCT_PLANT_TABLE_NAME = "ProductPlant" @Field final String PRODUCT_PLANT_PLANT_ATTRIBUTE = "attribute1" String tableNamePrefix = "${PRODUCT_PLANT_TABLE_NAME}__" def typeCode = "P" def sortBy = "sku" def fields = ["sku", "attribute1"] def distinctOnly = true def filters = [Filter.equal(tableNamePrefix + "${PRODUCT_PLANT_PLANT_ATTRIBUTE}", plant)] def products = libs.ACELib.LookupUtils.findAllItems(typeCode, sortBy, fields, distinctOnly, filters)

Found an issue in documentation? Write to us.