double-break / spapi-php

Amazon Selling Partner API PHP Client
MIT License
56 stars 48 forks source link

List all items from a seller #19

Closed SteveEdson closed 3 years ago

SteveEdson commented 3 years ago

Hi,

I've managed to authenticate now, but I'm having trouble getting all items from a particular seller (the one I'm authenticated as).

If I call

$sellers = new \DoubleBreak\Spapi\Api\Sellers($cred, $config);
print_r($sellers->getMarketplaceParticipations());

I can get a list of marketplaces, such as

 [10] => Array
                (
                    [marketplace] => Array
                        (
                            [id] => AZMDEXL2RVFNN
                            [countryCode] => GB
                            [name] => SI UK Prod Marketplace
                            [defaultCurrencyCode] => GBP
                            [defaultLanguageCode] => en_GB
                            [domainName] => siprodukmarketplace.stores.amazon.co.uk
                        )

                    [participation] => Array
                        (
                            [isParticipating] => 1
                            [hasSuspendedListings] => 
                        )

                )

But when I then try to get some catalog items using the marketplace id, I get a 404 error:

$catalogListing = new CatalogItems($cred, $config);

$result = $catalogListing->listCatalogCategories([
    'MarketplaceId' => 'AZMDEXL2RVFNN',
]);
print_r($result);
 Client error: `GET https://sellingpartnerapi-eu.amazon.com/catalog/v0/categories?MarketplaceId=AZMDEXL2RVFNN` resulted in a `404 Not Found` response:
{
  "errors": [
    {
      "code": "NotFound",
      "message": "The requested resource doesn\u0027t exist."
    }
  ]
 (truncated...)

Also, if I do the following:

$catalogListing = new CatalogItems($cred, $config);

$result = $catalogListing->listCatalogItems([
    'MarketplaceId' => 'AZMDEXL2RVFNN',
]);

I get the error:

{
  "errors": [
    {
      "code": "InvalidInput",
      "message": "Required parameter IdType not found",
      ...
    }
  ]
}

Any help here would be appreciated, thanks.

kingsun-he commented 3 years ago

Hi,

I've managed to authenticate now, but I'm having trouble getting all items from a particular seller (the one I'm authenticated as).

If I call

$sellers = new \DoubleBreak\Spapi\Api\Sellers($cred, $config);
print_r($sellers->getMarketplaceParticipations());

I can get a list of marketplaces, such as

 [10] => Array
                (
                    [marketplace] => Array
                        (
                            [id] => AZMDEXL2RVFNN
                            [countryCode] => GB
                            [name] => SI UK Prod Marketplace
                            [defaultCurrencyCode] => GBP
                            [defaultLanguageCode] => en_GB
                            [domainName] => siprodukmarketplace.stores.amazon.co.uk
                        )

                    [participation] => Array
                        (
                            [isParticipating] => 1
                            [hasSuspendedListings] => 
                        )

                )

But when I then try to get some catalog items using the marketplace id, I get a 404 error:

$catalogListing = new CatalogItems($cred, $config);

$result = $catalogListing->listCatalogCategories([
    'MarketplaceId' => 'AZMDEXL2RVFNN',
]);
print_r($result);
 Client error: `GET https://sellingpartnerapi-eu.amazon.com/catalog/v0/categories?MarketplaceId=AZMDEXL2RVFNN` resulted in a `404 Not Found` response:
{
  "errors": [
    {
      "code": "NotFound",
      "message": "The requested resource doesn\u0027t exist."
    }
  ]
 (truncated...)

Also, if I do the following:

$catalogListing = new CatalogItems($cred, $config);

$result = $catalogListing->listCatalogItems([
    'MarketplaceId' => 'AZMDEXL2RVFNN',
]);

I get the error:

{
  "errors": [
    {
      "code": "InvalidInput",
      "message": "Required parameter IdType not found",
      ...
    }
  ]
}

Any help here would be appreciated, thanks.

I try to add the parameter ASIN. It is OK. If without ASIN, it doesn't work. ` $catalogListing = new \DoubleBreak\Spapi\Api\CatalogItems($cred, $config);

$result = $catalogListing->listCatalogCategories([ 'MarketplaceId' => 'TEST_CASE_200', 'ASIN' => "asin_200" ]); print_r($result); `

SteveEdson commented 3 years ago

Have you had any luck with the listCatalogItems method? Thanks

kingsun-he commented 3 years ago

Hi SteveEdson,

I try this

$result = $catalogListing->listCatalogItems([ 'MarketplaceId' => 'TEST_CASE_200', 'SellerSKU' => "SKU_200" ]);

It is completly OK. @SteveEdson

SteveEdson commented 3 years ago

Is there a way to get all items from a specific seller? If I have to pass to a SKU won't that return just that item?

Sorry, I'm away from my PC so can't test right now.

kingsun-he commented 3 years ago

It seems that there is no such a function.

bastiaansenglenn commented 3 years ago

@SteveEdson for listCatalogItems() you need to provide a ASIN of a SellerSku.. There is no solution to get al your offers with this call.

There is a solution for your problem because i wanted the same and got it working! you need to work with Reports. https://github.com/double-break/spapi-php/blob/master/src/Api/Reports.php

I created a report for GET_MERCHANT_LISTINGS_ALL_DATA and after doing al the calls that are needed for getting your offers i retrieved my offers!

!NOTE! when you retrieved your offers, you need to decrypt them. Luckily in this package is a decrypter and i used parts of that class; https://github.com/double-break/spapi-php/blob/master/src/ASECryptoStream.php

When you have done all needed actions you will have a tab separated string with all your offers!

I hope you get a little further with this :)

lyubo-slavilov commented 3 years ago

I think @bastiaansenglenn gave the full answer. I am going to close this issue