allegro / allegro-api

Issue tracker and wiki for Allegro REST API
https://developer.allegro.pl/
217 stars 39 forks source link

Category Attributes IDs/values #10245

Open MBI910 opened 3 weeks ago

MBI910 commented 3 weeks ago

Hi there , attributes with IDs are quite difficult for us to handle since we have more to offer than Allegro shows us. For example, the attribute “dedicated brands” in the category “Electronics/Phones and Accessories/GSM Accessories/Protective Films and Glass”- you have like 150 brand to choose from. We have more than 2000 brands, that means we can manually connect 150 brands, and the rest goes into "others" it is not possible to send the text like “Apple”, we must submit ID: “207786_233798” which is a lot of work to do the mapping for us. It would be easier if we could send our text (Apple) and Allegro matches it with the ID.

Otherwise, we receive errors like this:

SKU: 2855687 Offer: 36069006 sending data: {"name":"upscreen Scratch Shield Clear Screen Protector for Garmin Xero C1 Pro","category":{"id":"10532"},"images":[{"url":"https:\/\/a.allegroimg.com\/original\/11ec3d\/dfd7e8ef489194a6d852e241407a"}],"language":"en-US","parameters":[{"id":"225693","valuesIds":[],"values":["4068489379181"],"rangeValue":null},{"id":"11323","valuesIds":["11323_1"],"values":[],"rangeValue":null},{"id":"219781","valuesIds":[],"values":["Xero C1 Pro"],"rangeValue":null},{"id":"224017","valuesIds":[],"values":["2855687"],"rangeValue":null},{"id":"248798","valuesIds":["248798_1678756"],"values":[],"rangeValue":null},{"id":"207786","valuesIds":["Garmin"],"values":[],"rangeValue":null},{"id":"207854","valuesIds":["207854_234030"],"values":[],"rangeValue":null},{"id":"207862","valuesIds":[],"values":["1"],"rangeValue":null}]} response data {"errors":[{"code":"UnableToCreateProductWithoutAllRequiredParametersException","message":"Unable to create product without proper values in all required parameters: [Dedykowana marka] in category: 10532","details":null,"path":"parameters","userMessage":"You cannot create a product without providing correct values for all the required parameters: [Dedicated brand]","metadata":{}}]} header data {"trace-id":"82ac390dc1133ef0","date":"Wed, 06 Nov 2024 07:01:28 GMT","content-type":"application\/json; charset=UTF-8","content-length":"384","x-frame-options":"DENY","strict-transport-security":"max-age=15552000","x-content-type-options":"nosniff"}

I think this is a general problem for everyone who is listing thousands of products via API not only for that specific Attribute in that specific category.

Allegro:

I asked our API for help with that questions and here is their answer:

This is something that the sellers, unfortunately, will not get around - sellers have to indicate a particular brand, while the others that they have in their database - they should actually pass on as "other".

But we could map by the name you pass on and according to the colleagues, this should work properly. My colleague tested one example with the brand and it works, so you should only pass the brand in the ‘values’ field, while ‘valuesIds’ should be removed from the request

Seller:

Is this applicable to every attribute in every category? That would be a gamechanger to a certain degree even if we cannot connect everything and have to use “other” for many. Maybe it is possible that Allegro extends the lists with data we can send you e.g. the 2000 brands we offer?

Allegro respond:

According to our API yes, it should work for every parameter.

Seller:

according to our IT specialist:

Please note the following: • ‘type’: ‘dictionary’ (selection), • only value_ids are permitted here • and ID 207786 is such a type, therefore only one ID may be entered here and not ‘Garmin’. • ‘type’: ‘range’ (range), • only ‘rangeValue’ => [ ‘from’ => XXXX, ‘to’ => XXXX ] may be filled • ‘type’: ‘float’ (decimal numbers), • only numbers may be transmitted here • for all other types that are not defined more precisely, the ‘values “ field is then filled as for ID 219781 (”type’: ‘string’) Please note, as this is important when filling the attributes, I cannot change anything here, these are the Allegro defaults.

As I told him that you tested it with your IT sending value text, he replied:

Okay, but how am I supposed to recognise whether this value belongs in value_ids or values? I can only follow their guidelines, and that's exactly what I've described. I can't put everything into value_ids and values, that certainly won't work. Then it would be nice if you could also tell me how I can recognise where I can enter something. Is there perhaps another parameter by which I can recognise something like this?

AureliuszBrussy commented 3 weeks ago

You can indeed use the names of the parameters, not just their IDs. You can get information about the parameters by using GET /sale/categories/{categoryId}/parameters. In the type field you will find information about the type of parameter supported values: dictionary (of single or multiple choice, depending on, the value in multipleChoices), integer and float, string (you can add one or more values).

You can also check if it is a range parameter by looking at the restrictions.range flag.

Below you can find samples of properly completed parameter structures, depending on their type:

or, just by using names (in name and values), for example:

{
         "name": "Brand",
         "values": [
             "Apple"
         ]
 }
MBI910 commented 3 weeks ago

@AureliuszBrussy Okay, so either IDs or names.... but how am I supposed to recognise what should be taken when, I can't just say if numbers or numbers with an underline then they are IDs otherwise names... that won't work.

PrzemyslawLukanowski commented 2 weeks ago

For dictionary-type parameters and it's values, you can always use ID or names. In this case, there's no need to use "if" logic, you can just choose it on your side. For the rest type of the parameters, the value type is related to a specific type of parameter, as in the documentation:

Zrzut ekranu 2024-11-12 o 08 30 47

When it comes to the parameters names (not values), you can always use names instead of IDs.

MBI910 commented 2 weeks ago

@PrzemyslawLukanowski somehow we still get an error sending the data:

sending data: {"name":"6x Savvies Screen Protector for Umidigi A5 Pro","category":{"id":"10532"},"images":[{"url":"https:\/\/a.allegroimg.com\/original\/114e50\/c9fb699848158658333433cac5af"}],"language":"en-US","parameters":[{"id":"225693","valuesIds":[],"values":["4062481067268"],"rangeValue":null},{"name":"Condition","valuesIds":[],"values":["New"],"rangeValue":null},{"name":"Dedicated brand","valuesIds":[],"values":["Umidigi"],"rangeValue":null},{"name":"Kind","valuesIds":[],"values":["protective film"],"rangeValue":null},{"id":"207862","valuesIds":[],"values":["6"],"rangeValue":null},{"id":"219781","valuesIds":[],"values":["Umidigi A5 Pro"],"rangeValue":null},{"id":"224017","valuesIds":[],"values":["1635924"],"rangeValue":null},{"name":"Manufacturer","valuesIds":[],"values":["Bedifol GmbH"],"rangeValue":null}]} response data {"errors":[{"code":"HttpMessageNotReadableException","message":"An error has occurred","details":null,"path":null,"userMessage":"Request contains invalid data. Contact the application author.","metadata":{}}]} header data {"trace-id":"393d72f64b8e7f9b","date":"Wed, 13 Nov 2024 15:10:36 GMT","content-type":"application\/json; charset=UTF-8","content-length":"209","x-frame-options":"DENY","strict-transport-security":"max-age=15552000","x-content-type-options":"nosniff"}

PrzemyslawLukanowski commented 2 weeks ago

@MBI910 I'm sorry for the misunderstanding, but I assumed that you were mentioning the POST /sale/product-offers resource which is our main approach to listing offers with products. Now I see in our logs that you are using POST /sale/product-proposals which is a different approach where you can propose a product first - in this case, you cannot use names, only IDs are supported.

MBI910 commented 1 week ago

@PrzemyslawLukanowski

We want to send the data for the category Attributes (dictionary) in the form ‘Name’ - ‘Values’. We create our new products via ‘/sale/product-proposals’ and our offers via ‘/sale/product-offers’. Since, according to your support, we cannot send the data in the form ‘Name’ - ‘Values’ when creating products via ‘/sale/product-proposals’, which endpoint do we have to use to send the product data for creation in order to be able to use ‘Name’ - ‘Values’?

PrzemyslawLukanowski commented 1 week ago

You should use POST /sale/product-offers. You can find more information in our tutorial.

MBI910 commented 1 week ago

@PrzemyslawLukanowski Can we also create non-existent products via [POST /sale/product-offers] instead of product-proposals?

PrzemyslawLukanowski commented 1 week ago

Yes, please check the mentioned tutorial:

Zrzut ekranu 2024-11-19 o 13 47 04
MBI910 commented 1 week ago

@PrzemyslawLukanowski

Now I really ask myself the question, why does the /sales/product-proposals exist? Since this is totally restricted (maximum number, updates only max. 200 per day) why does this exist if it is much easier with the /sale/product-offers and presumably the updates of the products are probably not limited to 200 per day!

PrzemyslawLukanowski commented 1 week ago

The /sale/product-proposals resource was introduced earlier than /sale/product-offers and it represents a different approach - you create only a product, without associating it with an offer within one request.

Since this is totally restricted (maximum number, updates only max. 200 per day) why does this exist if it is much easier with the /sale/product-offers and presumably the updates of the products are probably not limited to 200 per day!

There shouldn't be such limit on this resource, can you give me a sample trace-id where we returned this message? The limit on this resource is 20 000 created products per month.

MBI910 commented 1 week ago

@PrzemyslawLukanowski Which parameters are mandatory when creating products via /sale/product-offers The API documentation does not say what is required. And whether we also need images for the products here, or whether it is sufficient to send them via the offers?

PrzemyslawLukanowski commented 1 week ago

Required parameters for products are returned in the GET /sale/categories/{categoryID}/parameters and are marked as "requiredForProduct": true. It's described in this part of the tutorial, where you can also find information, about what needs to be done to create a new product - images of the product are also required:

Zrzut ekranu 2024-11-22 o 07 36 42
MBI910 commented 1 week ago

@PrzemyslawLukanowski Perhaps somewhat unfortunate wording the parameters clearly define which products are mandatory and which are not, but my question is more about the : name category id (can't actually exist, as it doesn't exist yet) idType images

PrzemyslawLukanowski commented 1 week ago

Id is required when you indicate a product from our catalog, idType in that type of approach is optional. Please check our tutorial, where both approaches are described and we mention, which fields need to be filled.