Skip to content

Commit f93f3e6

Browse files
committed
Add catalog URL slug to product response in catalog browse function
- Introduced a new variable, catalog_url_slug, to capture the catalog URL slug from product variants. - Updated the response structure in the catalog_browse function to include the catalog URL slug, enhancing the product details returned in the API response.
1 parent 3d56cd3 commit f93f3e6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

app/api/resources.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,16 @@ def catalog_browse(slug: str):
248248
variants = []
249249
lightest_g: float | None = None
250250
product_url: str | None = None
251+
catalog_url_slug: str | None = None
251252

252253
for v in variants_raw:
253254
w_g = _weight_to_grams(v.weight, v.weight_unit)
254255
if w_g is not None and (lightest_g is None or w_g < lightest_g):
255256
lightest_g = w_g
256257
if not product_url and v.product_url:
257258
product_url = v.product_url
259+
if not catalog_url_slug and v.catalog_url_slug:
260+
catalog_url_slug = v.catalog_url_slug
258261

259262
variants.append({
260263
"id": v.id,
@@ -271,6 +274,7 @@ def catalog_browse(slug: str):
271274
"brand_name": brand,
272275
"product_name": product,
273276
"product_url": product_url,
277+
"catalog_url_slug": catalog_url_slug,
274278
"lightest_weight_g": round(lightest_g, 2) if lightest_g is not None else None,
275279
"variants": variants,
276280
})

0 commit comments

Comments
 (0)