Attributes fetch by catalog

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!
traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Attributes fetch by catalog

Post by traiyani75 » 12 Dec 2019, 07:14

Hello,

We are implementing aimeos in mobile applications.
In that, we are getting all attributes using API
http://{domain-url}/jsonapi/attribute?include=media,text. Now we have an issue on this. This API is returning all the attributes. But we need only catalog related attributes to return. Cause we are showing these attributes into filter products screen.

For example, we have an attribute called Color & pattern, Now, the color attribute is used in mobile category and pattern attribute used into the cloths category.

Now, we are showing all phones via the smartphone catalog. So, in that listing we need to filter products by color only, we don't need another one.
Same for another catalog, we won't need a color attribute to display into the filter screen for a clothing catalog.

How do we distribute them among catalogs?

traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Re: Attributes fetch by catalog

Post by traiyani75 » 12 Dec 2019, 07:24

Also, we need to apply a filter on a product by category not directly over all products.

======

Along with that, I want to ask you that if I want to get catalog id from product details API. How do I get that with product details API (http://{domain-url}/product?id=18&include=attribute,media,price,product,product/property,text)

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

Re: Attributes fetch by catalog

Post by aimeos » 13 Dec 2019, 08:51

There are two ways to handle that:
1.) If you only have a limited number of attributes, you can fetch them upfront and use the product resource to retrieve the product counts for the attributes that match your current filter (e.g. f_catid and/or others)
2.) If your attribute number is potentially unlimited, you should retrive the product counts for the attributes machting the current filter first and use the returned attribute IDs to fetch the attributes using the attribute endpoint (limited by the attribute IDs)

Documentation:
- https://aimeos.org/docs/Developers/Clie ... attributes
- https://aimeos.org/docs/Developers/Clie ... ted_search
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Re: Attributes fetch by catalog

Post by traiyani75 » 13 Dec 2019, 09:25

I dont get the points, we need to get attributes based on catalogs. Currently, they are coming all at once

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

Re: Attributes fetch by catalog

Post by aimeos » 14 Dec 2019, 15:05

Attributes are not related to categories as long as you don't assign them to a category directly (the backend doesn't support that but the underlying data structures do).

Instead, you want the attributes where products exists for and that depends on the category you are displaying the products for. Thus, request the attribute counts for the currently displayed products first (this is an "attribute ID" -> "product count" map) and then retrieve the details of the attributes by their IDs in one more request.

If you want to save one request, you can also extend the attribute counts request to send the attribute details in the same request too. Aimeos is totally extensible so you can create your own responses.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply