Skip to content

Prices

This article contains all actions for retrieving and managing prices.

Tip

The price domain supports fetching related resources.

Get price by ID#

query {
  getPrice(id: "1", include: ["group"]) {
    id
    siteid
    type
    domain
    label
    currencyid
    quantity
    value
    costs
    rebate
    taxrates
    taxflag
    status
    mtime
    ctime
    editor
    lists {
      group {
        id
        item {
          id
          code
        }
      }
    }
    property {
      id
      type
      languageid
      value
    }
  }
}
Aimeos.query(`query {
  getPrice(id: "1", include: ["group"]) {
    id
    siteid
    type
    domain
    label
    currencyid
    quantity
    value
    costs
    rebate
    taxrates
    taxflag
    status
    mtime
    ctime
    editor
    lists {
      group {
        id
        item {
          id
          code
        }
      }
    }
    property {
      id
      type
      languageid
      value
    }
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`query {
  getPrice(id: "1", include: ["group"]) {
    id
    siteid
    type
    domain
    label
    currencyid
    quantity
    value
    costs
    rebate
    taxrates
    taxflag
    status
    mtime
    ctime
    editor
    lists {
      group {
        id
        item {
          id
          code
        }
      }
    }
    property {
      id
      type
      languageid
      value
    }
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "getPrice": {
      "id": "1",
      "siteid": "1.",
      "type": "default",
      "domain": "attribute",
      "label": "Demo: Large print",
      "currencyid": "EUR",
      "quantity": 1,
      "value": "15.00",
      "costs": "0.00",
      "rebate": "0.00",
      "taxrates": "{\\"tax\\":\\"20.00\\"}",
      "taxflag": true,
      "status": 1,
      "mtime": "2022-05-28 06:26:38",
      "ctime": "2022-05-28 06:26:38",
      "editor": "core:setup",
      "lists": {
        "group": [{
          "id": "10",
          "item": {
            "id": "2",
            "code": "wholesale"
          }
        }]
      },
      "property": [{
        "id": "1",
        "type": "country",
        "languageid": null,
        "value": "DE"
      }]
    }
  }
}

Search prices#

The filter parameter is explained in the filter section of the GraphQL basics article.

query {
  searchPrices(filter: "{\\"=~\\": {\\"price.label\\":\\"Demo\\"}}", include: ["group"]) {
    items {
      id
      siteid
      type
      domain
      label
      currencyid
      quantity
      value
      costs
      rebate
      taxrates
      taxflag
      status
      mtime
      ctime
      editor
      lists {
        group {
          id
          item {
            id
            code
          }
        }
      }
      property {
        id
        type
        languageid
        value
      }
    }
    total
  }
}
Aimeos.query(`query {
  searchPrices(filter: "{\\"=~\\": {\\"price.label\\":\\"Demo\\"}}", include: ["group"]) {
    items {
      id
      siteid
      type
      domain
      label
      currencyid
      quantity
      value
      costs
      rebate
      taxrates
      taxflag
      status
      mtime
      ctime
      editor
      lists {
        group {
          id
          item {
            id
            code
          }
        }
      }
      property {
        id
        type
        languageid
        value
      }
    }
    total
  }
}`).then(data => {
  console.log(data)
})
let filter = {
    "=~": {"price.label":"Demo"}
};
const fstr = JSON.stringify(JSON.stringify(filter));
const body = JSON.stringify({'query':
`query {
  searchPrices(filter: ` + fstr + `, include: ["group"]) {
    items {
      id
      siteid
      type
      domain
      label
      currencyid
      quantity
      value
      costs
      rebate
      taxrates
      taxflag
      status
      mtime
      ctime
      editor
      lists {
        group {
          id
          item {
            id
            code
          }
        }
      }
      property {
        id
        type
        languageid
        value
      }
    }
    total
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "searchPrices": {
      "items": [
        {
          "id": "3",
          "siteid": "1.",
          "type": "default",
          "domain": "attribute",
          "label": "Demo: Large print",
          "currencyid": "EUR",
          "quantity": 1,
          "value": "15.00",
          "costs": "0.00",
          "rebate": "0.00",
          "taxrates": "{\\"tax\\":\\"20.00\\"}",
          "taxflag": true,
          "status": 1,
          "mtime": "2022-05-28 06:26:38",
          "ctime": "2022-05-28 06:26:38",
          "editor": "core:setup",
          "lists": {
            "group": [{
              "id": "10",
              "item": {
                "id": "2",
                "code": "wholesale"
              }
            }]
          },
          "property": [{
            "id": "1",
            "type": "country",
            "languageid": null,
            "value": "DE"
          }]
        },
        {
          "id": "4",
          "siteid": "1.",
          "type": "default",
          "domain": "attribute",
          "label": "Demo: Large print",
          "currencyid": "USD",
          "quantity": 1,
          "value": "20.00",
          "costs": "0.00",
          "rebate": "0.00",
          "taxrates": "{\\"tax\\":\\"10.00\\"}",
          "taxflag": true,
          "status": 1,
          "mtime": "2022-05-28 06:26:38",
          "ctime": "2022-05-28 06:26:38",
          "editor": "core:setup",
          "lists": {
            "group": []
          },
          "property": [{
          }]
        }
      ],
      "total": 2
    }
  }
}

Save single price#

mutation {
  savePrice(input: {
    domain: "product",
    label: "Test price",
    currencyid: "EUR",
    value: "100.00",
    lists: {
      group: {
        refid: "2"
      }
    },
    property: [{
      type: "country",
      languageid: null,
      value: "DE"
    }]
  }) {
    id
  }
}
Aimeos.query(`mutation {
  savePrice(input: {
    domain: "product",
    label: "Test price",
    currencyid: "EUR",
    value: "100.00",
    lists: {
      group: {
        refid: "2"
      }
    },
    property: [{
      type: "country",
      languageid: null,
      value: "DE"
    }]
  }) {
    id
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  savePrice(input: {
    domain: "product",
    label: "Test price",
    currencyid: "EUR",
    value: "100.00",
    lists: {
      group: {
        refid: "2"
      }
    },
    property: [{
      type: "country",
      languageid: null,
      value: "DE"
    }]
  }) {
    id
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "savePrice": {
      "id": "30"
    }
  }
}

Save multiple prices#

mutation {
  savePrices(input: [{
    domain: "product",
    label: "Test 2 price",
    currencyid: "EUR",
    value: "200.00",
    lists: {
      group: [{
        refid: "2"
      }]
    },
    property: [{
      type: "country",
      languageid: null,
      value: "DE"
    }]
  },{
    domain: "product",
    label: "Test 3 price",
    currencyid: "USD",
    value: "220.00"
  }]) {
    id
  }
}
Aimeos.query(`mutation {
  savePrices(input: [{
    domain: "product",
    label: "Test 2 price",
    currencyid: "EUR",
    value: "200.00",
    lists: {
      group: [{
        refid: "2"
      }]
    },
    property: [{
      type: "country",
      languageid: null,
      value: "DE"
    }]
  },{
    domain: "product",
    label: "Test 3 price",
    currencyid: "USD",
    value: "220.00"
  }]) {
    id
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  savePrices(input: [{
    domain: "product",
    label: "Test 2 price",
    currencyid: "EUR",
    value: "200.00",
    lists: {
      group: [{
        refid: "2"
      }]
    },
    property: [{
      type: "country",
      languageid: null,
      value: "DE"
    }]
  },{
    domain: "product",
    label: "Test 3 price",
    currencyid: "USD",
    value: "220.00"
  }]) {
    id
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "savePrices": [
      {
        "id": "31"
      },
      {
        "id": "32"
      }
    ]
  }
}

Delete single price#

mutation {
  deletePrice(id: "30")
}
Aimeos.query(`mutation {
  deletePrice(id: "30")
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  deletePrice(id: "30")
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "deletePrice": "30"
  }
}

Delete multiple prices#

mutation {
  deletePrices(id: ["31", "32"])
}
Aimeos.query(`mutation {
  deletePrices(id: ["31", "32"])
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  deletePrices(id: ["31", "32"])
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "deletePrices": [
      "31",
      "32"
    ]
  }
}

Comments

Become an Aimeos Partner

Aimeos partners are first-class specialists in creating or hosting your Aimeos e-commerce project. They have proven their expertise by building top level e-commerce applications using Aimeos.