Rest api to get related products
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Rest api to get related products
Hello,
We are using aimeos rest apis into a mobile application for android and ios. We want to show related products with product details.
We have checked that in admin we have a feature to add similar products, But we have an issue in that.
Like in case, we need to show only 4-5 related products with the current one and if there are more products then we need to show "show more" options. How do we achieve this using rest apis.
Regards
Tejas
We are using aimeos rest apis into a mobile application for android and ios. We want to show related products with product details.
We have checked that in admin we have a feature to add similar products, But we have an issue in that.
Like in case, we need to show only 4-5 related products with the current one and if there are more products then we need to show "show more" options. How do we achieve this using rest apis.
Regards
Tejas
Re: Rest api to get related products
You can only retrieve all related products for a product using "/jsonapi/product/<id>?include=product" because the JSON:API standard doesn't support limiting related resources. Thus, you should use it mainly at the product detail page where only the current product with its related products is shown and the list of related products shouldn't be exessive. If the user clicks on "show more", you can display the remaining related products immediately without delay.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Re: Rest api to get related products
If we call API to get related products using product id, and we have related products about 30+ in counts.
So, do we have an API call to get the number of related products and also does that API will give pagination support? ?
So, do we have an API call to get the number of related products and also does that API will give pagination support? ?
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Re: Rest api to get related products
Hello, Along with this, if we will have 100+ similar products with one product then how can we get all those in the list that instead of manually add-in admin? Even, In admin, we need to add the product into a similar list on both sides which is also time-consuming.
Can we have any way to show all products into a similar list that belongs to the same subcategory or category?
Can we have any way to show all products into a similar list that belongs to the same subcategory or category?
Re: Rest api to get related products
If you don't want to show really related products but products from the same category, then use the product endpoint with the f_catid parameter. Then, you also have pagination and counts and don't need to populate the related products.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Re: Rest api to get related products
Now, In product details, we used this API
{product_url}?id=18&include=attribute,media,price,product/property,text
Using the above API, we are getting a response but we also need to return catalog details into the response. Like product belongs to which catalog. How do we achieve that thing?
We need catalog id because we are showing related products in the bottom of the product details screen
{product_url}?id=18&include=attribute,media,price,product/property,text
Using the above API, we are getting a response but we also need to return catalog details into the response. Like product belongs to which catalog. How do we achieve that thing?
We need catalog id because we are showing related products in the bottom of the product details screen
Re: Rest api to get related products
If the customer viewed the product list from the category, you know the category ID and can pass it as f_catid value.
If you need the categories the product is included in, you can retrieve them using the catalog endpoint and the "catalog:has" search function:
Afterwards, you can use the product endpoint to fetch the paginated product list using the "f_catid" parameter.
For this, you need:
In dev-master, there's already code available to get the categories directly along with the products.
If you need the categories the product is included in, you can retrieve them using the catalog endpoint and the "catalog:has" search function:
Code: Select all
.../catalog?filter[!=][catalog:has("product","default",<prodid>)]=
For this, you need:
Code: Select all
composer req aimeos/ai-controller-frontend:2019.10.x-dev aimeos/ai-client-jsonapi:2019.10.x-dev
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Re: Rest api to get related products
How do I get the catalog into product details directly? We want to open product details via notification and same time we will need to show related products too. So, We need to return catalog id into product details api too.
Also, there are some cases where the product list doesn't have catalog id. So, that time also when clicking on a product from the list, we need catalog id to have into the response.
How do I get catalog id direct from product details api?
Like for example api end point: {BASE_URL}/product?id=28&include=attribute,media,price,product,product/property,text
Also, there are some cases where the product list doesn't have catalog id. So, that time also when clicking on a product from the list, we need catalog id to have into the response.
How do I get catalog id direct from product details api?
Like for example api end point: {BASE_URL}/product?id=28&include=attribute,media,price,product,product/property,text
Re: Rest api to get related products
The product endpoint doesn't return the categories by default. You need to extend the JsonApi endpoint to fetch the categories for the products and add them to the response in the template:
- https://github.com/aimeos/ai-client-jso ... d.php#L315
- https://github.com/aimeos/ai-client-jso ... #L106-L133
- https://github.com/aimeos/ai-client-jso ... d.php#L315
- https://github.com/aimeos/ai-client-jso ... #L106-L133
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star