JSON API - get specific level of catalog from product

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
HADA
Posts: 5
Joined: 13 Apr 2021, 15:46

JSON API - get specific level of catalog from product

Post by HADA » 05 Jul 2021, 08:48

Hello Aimeos, thank you for your efforts again

I have a small issue, this is the structure of my catalog, products

  • Main Category
    • Level 1 Category
      • Sub Category
        • My product
My question is, what is the best way to get the "Level 1 Category" when fetching the product using the json API ( To be specific, I only need the catalog media).
When i add the "include = catalog" parameter, i only get the direct related category, which is the Sub Category.

Is there a clean way to solve my request. (I thought about fetching the Sub Category, but there is no parameter that allows us to get the parent catalog if i'm not mistaken)

Aimeos : 2021.04
Laravel 8

Thank you again !

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: JSON API - get specific level of catalog from product

Post by aimeos » 07 Jul 2021, 08:24

Yes, using "include=catalog" will only return "Sub Category" and there's no way to retrieve the parent category within the same request. Also, the parent ID isn't exposed via the JSON API at all.

The only option would be to fetch "Main Category" including all subcategories once (depending on how much categories you have this may or may not be an option) and check which is the parent category of "Sub Category".
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

stevencox
Posts: 1
Joined: 15 Jul 2021, 03:29

Re: JSON API - get specific level of catalog from product

Post by stevencox » 15 Jul 2021, 04:01

Thx, appreciate it.
All is clear.

HADA
Posts: 5
Joined: 13 Apr 2021, 15:46

Re: JSON API - get specific level of catalog from product

Post by HADA » 19 Jul 2021, 15:07

aimeos wrote: 07 Jul 2021, 08:24 Yes, using "include=catalog" will only return "Sub Category" and there's no way to retrieve the parent category within the same request. Also, the parent ID isn't exposed via the JSON API at all.

The only option would be to fetch "Main Category" including all subcategories once (depending on how much categories you have this may or may not be an option) and check which is the parent category of "Sub Category".

Thanks for you reply. In my case the option is doable, i only have few categories/subcategories

Post Reply