allegro / allegro-api

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

Produkt z ofertą - wymagane parametry do utworzenia produktu #5700

Closed Himon-SYNCRAFT closed 2 years ago

Himon-SYNCRAFT commented 2 years ago

Występuje problem:

:beetle: Opis / Description Witam korzystam na sandboxie z metody /sale/categories//parameters do pobrania infomarcji o parametrach dla kategorii o id 111867 (Akcesoria do kotłów i pieców) i w odpowiedzi dostaję:

{
  "parameters": [
    {
      "id": "11323",
      "name": "Stan",
      "type": "dictionary",
      "required": true,
      "requiredForProduct": false,
      "unit": null,
      "options": {
        "variantsAllowed": false,
        "variantsEqual": true,
        "ambiguousValueId": null,
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": false,
        "customValuesEnabled": false
      },
      "dictionary": [
        {
          "id": "11323_1",
          "value": "Nowy",
          "dependsOnValueIds": []
        },
        {
          "id": "11323_2",
          "value": "Używany",
          "dependsOnValueIds": []
        },
        {
          "id": "11323_238062",
          "value": "Uszkodzony",
          "dependsOnValueIds": []
        }
      ],
      "restrictions": {
        "multipleChoices": false
      }
    },
    {
      "id": "237190",
      "name": "Marka",
      "type": "string",
      "required": true,
      "requiredForProduct": true,
      "unit": null,
      "options": {
        "variantsAllowed": false,
        "variantsEqual": false,
        "ambiguousValueId": null,
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "restrictions": {
        "minLength": 1,
        "maxLength": 100,
        "allowedNumberOfValues": 1
      }
    },
    {
      "id": "214830",
      "name": "Rodzaj",
      "type": "dictionary",
      "required": true,
      "requiredForProduct": true,
      "unit": null,
      "options": {
        "variantsAllowed": false,
        "variantsEqual": false,
        "ambiguousValueId": "214830_268190",
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "dictionary": [
        {
          "id": "214830_1016596",
          "value": "adapter",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024162",
          "value": "automat palnikowy",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024160",
          "value": "blok gazowy",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1019365",
          "value": "czujnik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020203",
          "value": "deflektor",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024165",
          "value": "elektroda",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020208",
          "value": "filtr",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020207",
          "value": "grzałka",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016593",
          "value": "kolano",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020211",
          "value": "manometr",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016601",
          "value": "miarkownik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020202",
          "value": "naczynie przeponowe",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024164",
          "value": "odpowietrznik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016598",
          "value": "osłona",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024161",
          "value": "palnik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020200",
          "value": "płyn",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016597",
          "value": "pompa",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016592",
          "value": "radiator",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024163",
          "value": "regulator pokojowy",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016594",
          "value": "rozeta",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016595",
          "value": "rura",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020206",
          "value": "siłownik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020204",
          "value": "ślimak",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020201",
          "value": "sprzęgło",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020213",
          "value": "środek do czyszczenia",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_268182",
          "value": "sterownik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024166",
          "value": "syfon",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020209",
          "value": "sznur uszczelniający",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020212",
          "value": "termomanometr",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020210",
          "value": "termometr",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024167",
          "value": "termopara",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1019366",
          "value": "termostat",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016599",
          "value": "trójnik",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024158",
          "value": "uszczelka",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016600",
          "value": "wentylator",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1024159",
          "value": "wymiennik ciepła",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1016602",
          "value": "zapalarka",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_268186",
          "value": "zasilanie awaryjne",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_1020205",
          "value": "zawór",
          "dependsOnValueIds": []
        },
        {
          "id": "214830_268190",
          "value": "inny rodzaj",
          "dependsOnValueIds": []
        }
      ],
      "restrictions": {
        "multipleChoices": false
      }
    },
    {
      "id": "18235",
      "name": "Sposób montażu",
      "type": "dictionary",
      "required": false,
      "requiredForProduct": false,
      "unit": null,
      "options": {
        "variantsAllowed": true,
        "variantsEqual": false,
        "ambiguousValueId": null,
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "dictionary": [
        {
          "id": "18235_2",
          "value": "Stojące funkcyjne",
          "dependsOnValueIds": []
        },
        {
          "id": "18235_1",
          "value": "Wiszące",
          "dependsOnValueIds": []
        }
      ],
      "restrictions": {
        "multipleChoices": true
      }
    },
    {
      "id": "18236",
      "name": "Typ pieca",
      "type": "dictionary",
      "required": true,
      "requiredForProduct": true,
      "unit": null,
      "options": {
        "variantsAllowed": true,
        "variantsEqual": false,
        "ambiguousValueId": "18236_16",
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "dictionary": [
        {
          "id": "18236_2",
          "value": "dwufunkcyjny",
          "dependsOnValueIds": []
        },
        {
          "id": "18236_4",
          "value": "dwufunkcyjny z zasobnikiem cwu",
          "dependsOnValueIds": []
        },
        {
          "id": "18236_1",
          "value": "jednofunkcyjny",
          "dependsOnValueIds": []
        },
        {
          "id": "18236_8",
          "value": "komora spalania",
          "dependsOnValueIds": []
        },
        {
          "id": "18236_16",
          "value": "inny",
          "dependsOnValueIds": []
        }
      ],
      "restrictions": {
        "multipleChoices": true
      }
    },
    {
      "id": "17448",
      "name": "Waga produktu z opakowaniem jednostkowym",
      "type": "float",
      "required": false,
      "requiredForProduct": false,
      "unit": "kg",
      "options": {
        "variantsAllowed": false,
        "variantsEqual": false,
        "ambiguousValueId": null,
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "restrictions": {
        "min": 0,
        "max": 1000000,
        "range": false,
        "precision": 3
      }
    },
    {
      "id": "219809",
      "name": "Kod producenta",
      "type": "string",
      "required": true,
      "requiredForProduct": true,
      "unit": null,
      "options": {
        "variantsAllowed": false,
        "variantsEqual": false,
        "ambiguousValueId": null,
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "restrictions": {
        "minLength": 1,
        "maxLength": 40,
        "allowedNumberOfValues": 1
      }
    },
    {
      "id": "225693",
      "name": "EAN",
      "type": "string",
      "required": false,
      "requiredForProduct": false,
      "unit": null,
      "options": {
        "variantsAllowed": false,
        "variantsEqual": false,
        "ambiguousValueId": null,
        "dependsOnParameterId": null,
        "requiredDependsOnValueIds": null,
        "displayDependsOnValueIds": null,
        "describesProduct": true,
        "customValuesEnabled": false
      },
      "restrictions": {
        "minLength": 8,
        "maxLength": 14,
        "allowedNumberOfValues": 1
      }
    }
  ]
}

z której wynika, że parametr Sposób montażu (id 18235) nie jest parametrem wymaganym dla produktu ("requiredForProduct": false). Natomiast jak próbuje utworzyć aukcję razem z produktem (produkt nie istnieje, metoda POST na endpoint /sale/product-offers) dostaje w odpowiedzi bląd: ParameterCategoryException: Błędnie przesłano definicje parametru 18235:Sposób montażu jako parametr w sekcji offer.

Przykładowy request, który zwraca błąd:

  "afterSalesServices": {
    "impliedWarranty": {
      "id": "8cb47abe-c02b-4c61-b422-ed389b1900fa"
    },
    "returnPolicy": {
      "id": "1ea21122-323a-42b6-91b4-60861f17bd29"
    },
    "warranty": {
      "id": "67d32ffc-a19f-47e3-ac30-cbbdc9765bf1"
    }
  },
  "category": {
    "id": 111867
  },
  "delivery": {
    "shippingRates": {
      "id": "2d7298a8-59aa-43e2-ae92-a55d3710184f"
    },
    "handlingTime": "PT24H"
  },
  "description": {
    "sections": [
      {
        "items": [
          {
            "type": "TEXT",
            "content": "<h1>Zestaw do awaryjnego zasilania 100Ah 800W</h1>"
          }
        ]
      },
      {
        "items": [
          {
            "type": "IMAGE",
            "url": "https://allegro2.eltrox.pl/zdjecia/7871F/zestaw_do_awaryjnego_zasilania_100ah_800w_1570705946.jpg"
          },
          {
            "type": "TEXT",
            "content": "<h1>Najważniejsze cechy</h1><ul><li>Przetwornica 12V 800W</li><li>Akumulator 100Ah</li><li>Automatyczne przełączanie</li><li>Wbudowany prostownik</li><li>Pełny Sinus</li></ul>"
          }
        ]
      },
      {
        "items": [
          {
            "type": "TEXT",
            "content": "<h1>Zastosowanie</h1><p>Awaryjne zasilanie:</p><ul><li>Kotłów CO</li><li>Pomp</li><li>Sterowników pieca</li><li>Monitoringu</li><li>Alarmu</li><li>Bramy</li></ul>"
          }
        ]
      },
      {
        "items": [
          {
            "type": "IMAGE",
            "url": "http://www.eltrox.pl/zdjecia/przetwornice/7871_mini.jpg"
          },
          {
            "type": "TEXT",
            "content": "<h1>PRZETWORNICA SINUSPRO-800E 12V 500/800W</h1><ul><li>Moc ciągła do 500W</li><li>Moc impulsowa 800W</li><li>Napięcie wejściowe: 12V</li><li>Napięcie wyjściowe: 230V/10 50Hz/0.5</li><li>Przebieg napięcia: Czysty Sinus</li><li>Wyposażona w prostownik i UPS</li></ul>"
          }
        ]
      },
      {
        "items": [
          {
            "type": "IMAGE",
            "url": "https://allegro2.eltrox.pl/zdjecia/20405/akumulator-agm-opti-100ah-1.jpg"
          },
          {
            "type": "TEXT",
            "content": "<h1>Akumulator AGM OPTI 12V 100Ah</h1><ul><li>Pojemność: 100Ah</li><li>Napięcie: 12V</li><li>Technologia: AGM</li><li>Projektowana żywotność: 6-8 lat</li><li>Maksymalny prąd ładowania: 30A</li><li>Nie wymaga uzupełniania elektrolitu</li><li>Praca w dowolnej pozycji</li></ul>"
          }
        ]
      },
      {
        "items": [
          {
            "type": "TEXT",
            "content": "<h1></h1>"
          }
        ]
      },
      {
        "items": [
          {
            "type": "TEXT",
            "content": "<h1>W skład zestawu wchodzi</h1><ul><li>1 x Akumulator AGM OPTI 12V 100Ah 20405</li><li>1 x PRZETWORNICA SINUSPRO-800E 12V 500/800W 7871</li></ul>"
          }
        ]
      }
    ]
  },
  "ean": null,
  "external": {
    "id": "7871F"
  },
  "location": {
    "city": "Cała Polska",
    "countryCode": "PL",
    "postCode": "42-200",
    "province": "SLASKIE"
  },
  "name": "Zasilanie awaryjne pieca co ups pompy 800W",
  "parameters": [
    {
      "id": 18235,
      "valuesIds": [
        "18235_2"
      ],
      "required_for_product": false
    },
    {
      "id": 11323,
      "valuesIds": [
        "11323_1"
      ],
      "required_for_product": false
    },
    {
      "id": 17448,
      "values": [
        "35"
      ],
      "required_for_product": false
    }
  ],
  "stock": {
    "available": 100,
    "unit": "UNIT"
  },
  "sellingMode": {
    "format": "BUY_NOW",
    "price": {
      "amount": "909.00",
      "currency": "PLN"
    }
  },
  "productSet": [
    {
      "product": {
        "name": "Zasilanie awaryjne pieca co ups pompy 800W",
        "category": {
          "id": 111867
        },
        "parameters": [
          {
            "id": 237190,
            "values": [
              "SINUSPRO"
            ],
            "required_for_product": true
          },
          {
            "id": 219809,
            "values": [
              "SINUSPRO-800E"
            ],
            "required_for_product": true
          },
          {
            "id": 18236,
            "valuesIds": [
              "18236_2",
              "18236_4",
              "18236_1",
              "18236_8"
            ],
            "required_for_product": true
          },
          {
            "id": 214830,
            "valuesIds": [
              "214830_268186"
            ],
            "required_for_product": true
          }
        ],
        "images": [
          "https://allegro2.eltrox.pl/zdjecia/7871F/zestaw_do_awaryjnego_zasilania_100ah_800w_1570705946.jpg",
          "http://www.eltrox.pl/zdjecia/przetwornice/7871_mini.jpg",
          "https://allegro2.eltrox.pl/zdjecia/20405/akumulator-agm-opti-100ah-1.jpg"
        ]
      }
    }
  ],
  "payments": {
    "invoice": "NO_INVOICE"
  },
  "images": [
    "https://allegro2.eltrox.pl/zdjecia/7871F/zestaw_do_awaryjnego_zasilania_100ah_800w_1570705946.jpg",
    "http://www.eltrox.pl/zdjecia/przetwornice/7871_mini.jpg",
    "https://allegro2.eltrox.pl/zdjecia/20405/akumulator-agm-opti-100ah-1.jpg"
  ]
}

Jeśli przeniosę wartość parametru Sposób montażu do sekcji productSet to moge swobodnie wystawić produkt i teraz nie wiem czy dobrze rozumiem, że jesli tworzę produkt razem z aukcją to powinienem w sekcji productSet przekazywać tylko wartości dla parametrów oznaczonych jako requiredForProduct, a ten błąd, który dostaje zwrotnie to tylko kwestia niedociągnięć sandboxa czy może po prostu nie rozumiem tego i w jakiś inny sposób powienienem dojść, które parametry rzeczywiście są wymagane jeśli tworzę produkt z aukcją metodą /sale/product-offers? Dodam tylko, że ten sam problem występował na sandboxie jak próbowałem wystawiać aukcje w kategori 14237 (chyba kamey) dla parametrów Waga i Waga produktów z opakowaniem.

MaciejFrackowiak commented 2 years ago

Dobrze wywnioskowałeś - w sekcji parametrów produktu powinny znaleźć się te parametry, które mają flagę "requiredForProduct": true. Rzeczywiście, w opisanym przypadku Sposób montażu ma flagę ustawioną na false, jednak nie ma możliwości stworzenia oferty z produktem, gdy przekażemy Sposób montażu jako parametr ofertowy. Jest to "urok" Sandboxa, gdzie aktualizacja kategorii i parametrów odbywa się raz na kwartał - tj. tylko bezpośrednio po takiej aktualizacji stan faktyczny powinien być w 100% zgodny. Niestety, z kolejnymi dniami może dochodzić do rozbieżności - ktoś zmieni wartość flagi, jednak w układzie parametrów i kategorii ta zmiana nie znajdzie już swojego odzwierciedlenia. Ostatnia aktualizacja miała miejsce 5 kwietnia 2022, o czym informowaliśmy w poście.

Himon-SYNCRAFT commented 2 years ago

Szkoda, że tak wygląda sytuacja bo liczyłem, że uda mi się trochę testy zautomatyzować, ale w takim przypadku będzie ciężko i nie ma to sensu. Ale dziękuję za informację :)

Himon-SYNCRAFT commented 2 years ago

Witam.

Niestety mam podobny problem na środowisku produkcyjnym: Pobralem za pomocą endpointu /sale/categories/4439/parameters informację o paremetrach dla kategorii Komputery/Urządzenia sieciowe/Sprzęt sieciowy/Transceiver i konwertery. W odpowiedzi dostaję zwrotnie informację, że Waga produktu z opakowaniem jednostkowym nie jest wymaganym parametrem do utworzenia produktu: (requiredForProduct: false).

Przy próbie wystawienia aukcji z produktem (korzystam z /sale/product-offers) dostaje informację: "ParameterCategoryException: Błędnie przesłano definicje parametru 17448:Waga produktu z opakowaniem jednostkowym jako parametr w sekcji offer

MaciejFrackowiak commented 2 years ago

Proszę podaj trace-id Twojego wywołania, sprawdzę to.

Himon-SYNCRAFT commented 2 years ago

trace-id: 7d178647e89454d9

MaciejFrackowiak commented 2 years ago

Dziękuję za przykład. Oprócz flagi "requiredForProduct", która mówi o obowiązkowości danego parametru przy tworzeniu produktu, kluczowa jest także flaga "options.describesProduct" - ona mówi, czy dany parametr opisuje produkt czy ofertę. W przypadku kategorii 4439 przy "options.describesProduct" widnieje true, zatem ten parametr powinien znaleźć się w sekcji produktowej parametrów, a nie ofertowej.

Himon-SYNCRAFT commented 2 years ago

Rzeczywiście uciekła mi ta informacja. Dziękuje za pomoc :)

stale[bot] commented 2 years ago

W tym wątku nie pojawiła się żadna nowa odpowiedź w ciągu 7 dni, dlatego automatycznie oznaczamy go jako przeterminowany. Jeśli w ciągu kolejnych 7 dni nie pojawi się żadna odpowiedź, wątek zostanie zamknięty. Dziękujemy za zaangażowanie w dyskusję i zachęcamy Cię do wypełnienia ankiety dotyczącej naszego wsparcia na forum.


There was no new reply in this thread within 7 days, therefore, we automatically marked it as expired. If no response is received within the next 7 days, this thread will be closed. Thank you for engaging in the discussion. We encourage you to complete our forum support survey.