selling-partner-api icon indicating copy to clipboard operation
selling-partner-api copied to clipboard

ItemSearchResults __construct fails, if the response misses the pagination information

Open KhorneHoly opened this issue 8 months ago • 2 comments

Example response:

{
    "items": [
        {
            "asin": "3465018532",
            "attributes": {
                "binding": [
                    {
                        "marketplace_id": "A1PA6795UKMFR9",
                        "value": "hardcover"
                    }
                ],
                "externally_assigned_product_identifier": [
                    {
                        "marketplace_id": "A1PA6795UKMFR9",
                        "type": "isbn",
                        "value": "3465018532"
                    },
                    {
                        "marketplace_id": "A1PA6795UKMFR9",
                        "type": "ean",
                        "value": "9783465018537"
                    }
                ],
                "item_name": [
                    {
                        "language_tag": "de_DE",
                        "marketplace_id": "A1PA6795UKMFR9",
                        "value": "Revolution, Reform, Restauration. Formen der Veränderung von Recht und Gesellschaft"
                    }
                ],
                "product_site_launch_date": [
                    {
                        "marketplace_id": "A1PA6795UKMFR9",
                        "value": "2007-01-30T02:57:53-00:00"
                    }
                ],
                "recommended_browse_nodes": [
                    {
                        "marketplace_id": "A1PA6795UKMFR9",
                        "value": "3355581"
                    }
                ]
            },
            "dimensions": [
                {
                    "marketplaceId": "A1PA6795UKMFR9"
                }
            ],
            "identifiers": [
                {
                    "identifiers": [
                        {
                            "identifier": "9783465018537",
                            "identifierType": "EAN"
                        },
                        {
                            "identifier": "3465018532",
                            "identifierType": "ISBN"
                        }
                    ],
                    "marketplaceId": "A1PA6795UKMFR9"
                }
            ],
            "images": [
                {
                    "images": [],
                    "marketplaceId": "A1PA6795UKMFR9"
                }
            ],
            "salesRanks": [
                {
                    "classificationRanks": [],
                    "displayGroupRanks": [],
                    "marketplaceId": "A1PA6795UKMFR9"
                }
            ],
            "summaries": [
                {
                    "adultProduct": false,
                    "autographed": false,
                    "browseClassification": {
                        "classificationId": "143",
                        "displayName": "Politik & Geschichte"
                    },
                    "itemClassification": "BASE_PRODUCT",
                    "itemName": "Revolution, Reform, Restauration. Formen der Veränderung von Recht und Gesellschaft",
                    "marketplaceId": "A1PA6795UKMFR9",
                    "memorabilia": false,
                    "tradeInEligible": false,
                    "websiteDisplayGroup": "book_display_on_website",
                    "websiteDisplayGroupName": "Book"
                }
            ]
        }
    ],
    "numberOfResults": 1
}

This triggers the following error: request.CRITICAL: Uncaught PHP Exception ArgumentCountError: "SellingPartnerApi\Seller\CatalogItemsV20220401\Responses\ItemSearchResults::__construct(): Argument #2 ($pagination) not passed" at ItemSearchResults.php line 29

Same issue is true for the refinements. By the documentation both are required in the response, but truth is that both might be missing. Just do a search with a single ASIN to force a response with a single item found.

Since this is a generated class, how would be go about solving this issue? Manually changing the JSON used for generation doesn't seem future proof to me.

KhorneHoly avatar Jun 24 '24 09:06 KhorneHoly