# Erweiterte Preise für Produkt mit API hinzufügen

**URL:** <https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703>\
**Category:** Allgemein\
**Created:** [30. Juli 2020 um 14:29 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703 "2020-07-30T14:29:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![balram](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@balram](https://forum.shopware.com/u/balram)\
**Post date:** [30. Juli 2020 um 14:29 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/1 "2020-07-30T14:29:43Z")

</div>

Hallo Leute,

ich möchte mit der API Erweiterte Preise durch POST&nbsp;hinzufügen. Mit erweiterten Preisen meine ich z.B. dass ein Produkt von 0-5 Stück 10€ kostet und von 6-10 Stück 15€.

Wäre euch dankbar für eure Ideen! 🙂

Gruß

Balram

---

<div class="post-metadata">

**Author:** ![ThomasChr](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomaschr/32/10466_2.png) [@ThomasChr](https://forum.shopware.com/u/ThomasChr)\
**Post date:** [31. Juli 2020 um 09:42 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/2 "2020-07-31T09:42:15Z")

</div>

Kann mit Python dienen:

```
payload["price"] = []
payload["price"].append({})
payload["price"][0]["currencyId"] = "b7d2554b0ce847cd82f3ac9bd1c0dfca"
payload["price"][0]["net"] = float(str("7,890").replace(",", "."))
payload["price"][0]["gross"] = float(str("9,152").replace(",", "."))
payload["price"][0]["linked"] = True
payload["prices"] = []
payload["prices"].append({})
payload["prices"][0]["ruleId"] = "9402e2cad7144f22a6dfdb2adf2fdfc4"
payload["prices"][0]["quantityStart"] = 0
payload["prices"][0]["quantityEnd"] = 14
payload["prices"][0]["price"] = []
payload["prices"][0]["price"].append({})
payload["prices"][0]["price"][0]["currencyId"] = "b7d2554b0ce847cd82f3ac9bd1c0dfca"
payload["prices"][0]["price"][0]["net"] = float(str("7,890").replace(",", "."))
payload["prices"][0]["price"][0]["gross"] = float(str("9,152").replace(",", "."))
payload["prices"][0]["price"][0]["linked"] = True
payload["prices"].append({})
payload["prices"][1]["ruleId"] = "9402e2cad7144f22a6dfdb2adf2fdfc4"
payload["prices"][1]["quantityStart"] = 15
payload["prices"][1]["quantityEnd"] = 359
payload["prices"][1]["price"] = []
payload["prices"][1]["price"].append({})
payload["prices"][1]["price"][0]["currencyId"] = "b7d2554b0ce847cd82f3ac9bd1c0dfca"
payload["prices"][1]["price"][0]["net"] = float(str("7,100").replace(",", "."))
payload["prices"][1]["price"][0]["gross"] = float(str("8,236").replace(",", "."))
payload["prices"][1]["price"][0]["linked"] = True
payload["prices"].append({})
payload["prices"][2]["ruleId"] = "9402e2cad7144f22a6dfdb2adf2fdfc4"
payload["prices"][2]["quantityStart"] = 360
payload["prices"][2]["quantityEnd"] = 9999999
payload["prices"][2]["price"] = []
payload["prices"][2]["price"].append({})
payload["prices"][2]["price"][0]["currencyId"] = "b7d2554b0ce847cd82f3ac9bd1c0dfca"
payload["prices"][2]["price"][0]["net"] = float(str("5,920").replace(",", "."))
payload["prices"][2]["price"][0]["gross"] = float(str("6,867").replace(",", "."))
payload["prices"][2]["price"][0]["linked"] = True

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![ThomasChr](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomaschr/32/10466_2.png) [@ThomasChr](https://forum.shopware.com/u/ThomasChr)\
**Post date:** [31. Juli 2020 um 09:57 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/3 "2020-07-31T09:57:48Z")

</div>

Oh: Endpoint ist in diesem Fall natürlich /product

---

<div class="post-metadata">

**Author:** ![balram](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@balram](https://forum.shopware.com/u/balram)\
**Post date:** [31. Juli 2020 um 12:38 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/4 "2020-07-31T12:38:11Z")

</div>

@ThomasChr‍, ersteinmal Danke für deine Antwort. Kann ich das auch ohne Python direkt in JSON in dem POST machen?

Gruß Balram

---

<div class="post-metadata">

**Author:** ![ThomasChr](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomaschr/32/10466_2.png) [@ThomasChr](https://forum.shopware.com/u/ThomasChr)\
**Post date:** [31. Juli 2020 um 13:43 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/5 "2020-07-31T13:43:58Z")

</div>

Na klar. Das war ja nur ein Beispiel wie es in Python geht. Du musst nur dein JSON genauso schreiben.

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [31. Juli 2020 um 13:58 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/6 "2020-07-31T13:58:27Z")

</div>

Die Api hat bei den Preisen die Felder ‘from’ und ‘to’, ergo kannst du hier einfach verschiedene Einträge hinterlegen für deine Preisstaffeln, die bis auf from,to und price immer ähnlich aufgebaut sind.

Am Einfachsten wäre es, wenn du im Backend einen Preis manuell mit Staffelpreisen versiehst, diesen mal testweise über die Api abrufst und dann versuchst das Konstrukt für deinen Fall nachzubauen.

```
"prices":[
            {
               . . .
               "customerGroupKey":"EK",
          --> "from":1,
          --> "to":2,
               "price":12.563025210084,
               . . .
            }
            {
              / / 
              "from":2,
              "to":"3,
              / /
            }
            usw.
]
```

---

<div class="post-metadata">

**Author:** ![balram](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@balram](https://forum.shopware.com/u/balram)\
**Post date:** [17. August 2020 um 08:52 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/7 "2020-08-17T08:52:17Z")

</div>

Hi @PStadtfeld‍,&nbsp;

Danke für deine Hilfe, habs jetzt mal einfach so ausprobiert mit dem product POST:

```
{
    "name": "Abstandsbolzen mit Snap 1ps",
    "description": "Dies ist ein runder Abstandsbolzen mit Snap 1",
    "stock": 10000,
    "productNumber": "404.09.05",
    "prices": [
                    {
                        "from": 1,
                        "to": 3,
                        "currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
                        "gross": 15,
                        "net": 10,
                        "linked": false
                    },

                    {
                        "from": 4,
                        "to": 7,
                        "currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
                        "gross": 10,
                        "net": 5,
                        "linked": false
                    }
    ],

    "manufacturerId": "c5543f3ecde04616b7e7a2c237e70d5e",
    "tax": {
        "name": "test",
        "taxRate": 15
    },
    "properties": [
        {
            "id": "2bfd278e87204807a890da4a3e81dd90",
            "groupID": "269c7e40a54a462e884edb004c5f7bc8"
        },
        {
            "id": "591112ae031f42759797d6ca256bdeb5",
            "groupID": "269c7e40a54a462e884edb004c5f7bc8"
        }
    ],
    "categories": [
        {
            "id": "c0637b16eb2d4161bf7e3c49a174a960"
        }
    ],
    "visibilities": [
        {
            "salesChannelId": "cc6563a3db684b1d9a7edbe34453a205",
            "visibility": 30 
        }
    ]
}

```

Es wird mir aber gesagt, dass&nbsp;price, ruleId, quantityStart usw. nicht leer sein sollen:

```
{
    "errors": [
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/price"
            }
        },
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/prices/0/ruleId"
            }
        },
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/prices/0/price"
            }
        },
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/prices/0/quantityStart"
            }
        },
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/prices/1/ruleId"
            }
        },
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/prices/1/price"
            }
        },
        {
            "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
            "status": "400",
            "detail": "Dieser Wert sollte nicht leer sein.",
            "template": "This value should not be blank.",
            "meta": {
                "parameters": {
                    "{{ value }}": "null"
                }
            },
            "source": {
                "pointer": "/0/prices/1/quantityStart"
            }
        }
    ]
}

```

Die Frage ist, woher bekomme ich diese Werte?

Gruß

balram

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [19. August 2020 um 12:12 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/8 "2020-08-19T12:12:56Z")

</div>

Woher der Preis kommt? Den willst du doch darüber setzen, also solltest&nbsp; du den kennen…

QuantityStart und RuleID sagen mir leider nichts, da ich bisher nur in ShopwareV5 unterwegs war.

---

<div class="post-metadata">

**Author:** ![balram](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@balram](https://forum.shopware.com/u/balram)\
**Post date:** [20. August 2020 um 14:15 UTC](https://forum.shopware.com/t/erweiterte-preise-fur-produkt-mit-api-hinzufugen/68703/9 "2020-08-20T14:15:27Z")

</div>

Quantity Start ist einfach für den Start der Menge und die RuleID bekommt man aus dem /rule GET. Da wählt man die RuleID, die für „überall sichtbar“ steht.
