Erweiterte Preise per Rest API

Ja, habe ich :slight_smile:

Das hier schicke ich als Payload über die sync API… allerdings hole ich mir vorher über einen gesamten Dump die Preis-IDs der betroffenen zu aktualisierenden Einträge und speichere mir die zur Verarbeitung in einem record. 

Letztlich schicke ich in einem Block die deletes und dann anschliessend die inserts … alles in einem Payload. 

Hier mein Payload:

{
   "delete-prices-10013363-1":{
      "entity":"product_price",
      "action":"delete",
      "payload":[
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "id":"5f8f5991f3ad4785a8aea276a08e0a2a"
         },
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "id":"e05a760ac0654823a53d41fa57207056"
         },
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "id":"e1515f82dab3445b88957adba9d0c5ba"
         }
      ]
   },
   "insert-prices-10013363-1":{
      "entity":"product_price",
      "action":"upsert",
      "payload":[
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "ruleId":"92c24dd21c13419c8275a65f48d19975",
            "price":[
               {
                  "currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
                  "net":1.79,
                  "linked":true,
                  "gross":2.1301
               }
            ],
            "quantityStart":1,
            "quantityEnd":71
         },
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "ruleId":"92c24dd21c13419c8275a65f48d19975",
            "price":[
               {
                  "currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
                  "net":1.69,
                  "linked":true,
                  "gross":2.0111
               }
            ],
            "quantityStart":72,
            "quantityEnd":215
         },
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "ruleId":"92c24dd21c13419c8275a65f48d19975",
            "price":[
               {
                  "currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
                  "net":1.49,
                  "linked":true,
                  "gross":1.7731
               }
            ],
            "quantityStart":216,
            "quantityEnd":null
         }
      ]
   },
   "delete-prices-10013363-3":{
      "entity":"product_price",
      "action":"delete",
      "payload":[
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "id":"a5b72035697d40bb8e67da9370f66c6c"
         }
      ]
   },
   "insert-prices-10013363-3":{
      "entity":"product_price",
      "action":"upsert",
      "payload":[
         {
            "productId":"f6d7a38eea064818bbba1b8dd0b7328d",
            "ruleId":"b689215513f94d199e112248173557c5",
            "price":[
               {
                  "currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
                  "net":1.49,
                  "linked":true,
                  "gross":1.7731
               }
            ],
            "quantityStart":1,
            "quantityEnd":null
         }
      ]
   },
}

Hier noch der Link zur offiziellen Doku, wo auch beschrieben steht, warum ich keys verwende… wie “insert-prices-10013363-3”

https://docs.shopware.com/en/shopware-platform-dev-en/admin-api-guide/sync-api

Grüße

Holger 

3 „Gefällt mir“