JSON API “website_id” in tier price create
-
20-02-2021 - |
Domanda
I've already got products and stock updates going back and forth via the JSON API, and I'm now working on orders and prices for each store view - each one has a different currency, therefore different price values.
To push prices, I call rest/V1/products/tier-prices
and specify:
{
"prices": [
{
"price": 11,
"price_type": "fixed",
"sku": "sku_goes_here",
"website_id": ???,
"customer_group": "all groups",
"quantity": 1
}
]
}
But, I don't know what the website_id
is. I load products etc. using the URL store view like rest/store2view/V1/products
. This is a mandatory field.
I can get the website_ids for each item, but this is just a list of numbers, with no link back to which view they are.
How do I convert the store2view
name into a website ID?
Soluzione
Each Magento installation has website ids and store ids. Tier prices are scoped per website so you will need a website id to store them.
You can retrieve the list of your websites with a GET on /V1/store/websites
You can also find them in de database table under store_website
. If you only use 1 website it normally had id 1
. If it is for an extension you need to rely on the fact that one might have more then 1 website on their Magento installation.