JSON API - Double Relationship resources

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Kevin1596
Posts: 28
Joined: 13 Aug 2020, 10:11

JSON API - Double Relationship resources

Post by Kevin1596 » 15 Dec 2020, 04:46

Aimeos laravel 2020.10*

when I called API to catalog endpoint to get the data
with var params = {
include: 'catalog,product,text,media'
};

the response have the double of TEXT resources of the included Catalog

Code: Select all

var url = `https://laravel.demo.aimeos.org/default/jsonapi`; // Base URL from config

var promise = $.ajax( url, {
    method: "OPTIONS",
    dataType: "json"
});

promise.done( function( options ) {
    var args = {};
    var params = {
    include: 'catalog,product,text,media'
};
    console.log(options)
    console.log('end points')
    console.log(options.meta.resources)

    var result = $.ajax({
        method: "GET",
        dataType: "json",
        url: `${options.meta.resources['catalog']}`,
        data: params
    });

    result.done( function( result ) {
        console.log('resource data')
        console.log( result.data );
    });
});
Screen Shot 2020-12-15 at 11.46.06 AM.png
Screen Shot 2020-12-15 at 11.46.06 AM.png (115.98 KiB) Viewed 5696 times

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

Re: JSON API - Double Relationship resources

Post by aimeos » 17 Dec 2020, 13:51

If you add "include=catalog", the response will also include all subcategories and these categories have texts, images and prodducts themselves which are also added in the "included" section.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Kevin1596
Posts: 28
Joined: 13 Aug 2020, 10:11

Re: JSON API - Double Relationship resources

Post by Kevin1596 » 18 Dec 2020, 04:07

the problem is in the Included Catalog:
the relate texts of included catalog are doubled
Example: as the screen shot we have text with Id 40727 is double

User avatar
Kevin1596
Posts: 28
Joined: 13 Aug 2020, 10:11

Re: JSON API - Double Relationship resources

Post by Kevin1596 » 18 Dec 2020, 04:57

you could check it by calling my request on https://laravel.demo.aimeos.org/default and review the response

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

Re: JSON API - Double Relationship resources

Post by aimeos » 18 Dec 2020, 08:18

You are right, the relationship entries for texts are duplicate:
https://laravel.demo.aimeos.org/default ... retty=true
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

Re: JSON API - Double Relationship resources

Post by aimeos » 18 Dec 2020, 10:29

OK, it's fixed in aimeos/ai-client-jsonapi:2020.10.x-dev
Can you confirm?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Kevin1596
Posts: 28
Joined: 13 Aug 2020, 10:11

Re: JSON API - Double Relationship resources

Post by Kevin1596 » 18 Dec 2020, 15:02

I will confirm it!

another point is, It seems that Stock also got relate problem

Image

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

Re: JSON API - Double Relationship resources

Post by aimeos » 20 Dec 2020, 14:03

Your screenshot is missing. Can you also post an URL of the demo installation where we can see the problem?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply