in projects/conversational-commerce-agent/data-ingestion/cosmetics_to_retail_search.py [0:0]
def update_attributes(source_obj) -> dict:
"""
Update site level attribute controls
Args:
source_obj: source product attribute controls
Returns:
dict: updated attribute controls
"""
target_obj = {
"attributes" : {}
}
colors = source_obj.get("product_colors", [])
if colors is not None and colors != []:
c = {
"text": [
color["colour_name"] for color in colors
if "colour_name" in color and
color["colour_name"] is not None and
color["colour_name"] != ""
]
}
if c["text"] != []:
target_obj["attributes"]["Color"] = c
target_obj["attributes"]["Color"]["searchable"] = True
target_obj["attributes"]["Color"]["indexable"] = True
if ("tag_list" in source_obj and
source_obj["tag_list"] is not None and
source_obj["tag_list"] != []):
target_obj["attributes"]["Tags"] = {
"text": source_obj.get("tag_list", [])
}
target_obj["attributes"]["Tags"]["searchable"] = True
target_obj["Tags"] = {
"text": source_obj.get("tag_list", [])
}
return target_obj["attributes"]