In this part of the documentation, you can learn more about the API's variants resource. With this resource, it's possible to retrieve, delete and update any variant in your shops. We will also have a look at the associated data structures.
This resource supports the following operations:
Access URL | GET | GET (List) | PUT | PUT (Batch) | POST | DELETE | DELETE (Batch) |
---|---|---|---|---|---|---|---|
/api/variants |
If you want to access this resource, simply query the following URL
You can retrieve the variants data by providing the specific id
Identifier | Parameter | Database Column | Example call |
---|---|---|---|
Detail id | id | s_articles_details.id |
/api/variants/2 |
Detail number | number | s_articles_details.ordernumber |
/api/variants/SW10003?useNumberAsId=true |
Option parameters can be provided:
* considerTaxInput
: By default, all returned prices are net values.
If the boolean considerTaxInput
is set to true, gross values will be returned instead.
Model | Table |
---|---|
Shopware\Models\Article\Detail | s_articles_details |
Field | Type | Original object |
---|---|---|
id | integer (primary key) | |
articleId | integer (foreign key) | Article |
unitId | integer (foreign key) | |
number | string | |
supplierNumber | string | |
kind | integer | |
additionalText | string | |
active | boolean | |
inStock | integer | |
stockMin | integer | |
weight | string | |
len | string | |
height | string | |
ean | string | |
position | integer | |
minPurchase | integer | |
purchaseSteps | integer | |
maxPurchase | integer | |
purchaseUnit | string | |
shippingFree | boolean | |
releaseDate | date/time | |
shippingTime | string | |
prices | array | Price |
attribute | object | Attribute |
configuratorOptions | array | ConfiguratorOptions |
To post a variant, you need to provide the data as shown below:
You can use this data to add a new variant to the shop
Model | Table |
---|---|
Shopware\Models\Article\Detail | s_articles_details |
Field | Type | Original object |
---|---|---|
id | integer (primary key) | |
articleId | integer (foreign key) | Article |
unitId | integer (foreign key) | |
number | string | |
supplierNumber | string | |
kind | integer | |
additionalText | string | |
active | boolean | |
inStock | integer | |
stockMin | integer | |
weight | string | |
len | string | |
height | string | |
ean | string | |
position | integer | |
minPurchase | integer | |
purchaseSteps | integer | |
maxPurchase | integer | |
purchaseUnit | string | |
shippingFree | boolean | |
releaseDate | date/time | |
shippingTime | string | |
prices | array | Price |
attribute | object | Attribute |
configuratorOptions | array | ConfiguratorOptions |
You can post or put data by sending the following data to this URL:
To put data to a variant, simply provide one of the following parameters to identify it:
Identifier | Parameter | Database Column | Example Call |
---|---|---|---|
Detail Id | id | s_articles_details.id |
/api/variants/2 |
Detail number | number | s_articles_details.ordernumber |
/api/variants/SW10003?useNumberAsId=true |
The data is the same as shown in the POST operation.
You can use this data to update a variant.
Model | Table |
---|---|
Shopware\Models\Article\Detail | s_articles_details |
Field | Type | Original object |
---|---|---|
id | integer (primary key) | |
articleId | integer (foreign key) | Article |
unitId | integer (foreign key) | |
number | string | |
supplierNumber | string | |
kind | integer | |
additionalText | string | |
active | boolean | |
inStock | integer | |
stockMin | integer | |
weight | string | |
len | string | |
height | string | |
ean | string | |
position | integer | |
minPurchase | integer | |
purchaseSteps | integer | |
maxPurchase | integer | |
purchaseUnit | string | |
shippingFree | boolean | |
releaseDate | date/time | |
shippingTime | string | |
prices | array | Price |
attribute | object | Attribute |
configuratorOptions | array | ConfiguratorOptions |
To delete a variant, simply provide one of the following parameters to identify it:
Identifier | Parameter | Database Column | Example Call |
---|---|---|---|
Detail Id | id | s_articles_details.id |
/api/variants/2 |
Detail number | number | s_articles_details.ordernumber |
/api/variants/SW10003?useNumberAsId=true |
In order to delete more than one variant at once, it's possible to provide an array of ids to the REST API. Simply pass the array of article ids to the following URL (example)
without providing an id as seen in the single DELETE
request. As data provide the array of ids you wish to delete.
Updating many articles at once requires an array of variant data being provided to the following URL using the PUT
request (example):
Simply provide the same data as described in the "create! statement.