Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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))?

...

hiddentrue

...

Answer

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

Example

Code Block
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)