1

My Magento 2.2.4 codebase runs multiple websites, and I am trying to add a product via API to a website with id of "4".

here's the payload of my POST request I tried:

{
  "product": {
    "sku": "000012553333",
    "name": "B21232",
    "price": 30.03,
    "status": 1,
    "type_id": "simple",
    "attribute_set_id":4,
    "weight": 1,
    "extension_attributes": {
        "website_ids": [4]
    }
  }
}

here's the endpoint:

https://example.com/rest/V1/products

So it adds the product to the website I want AND TO THE DEFAULT website.

So how do I get Magento 2 to add product to a specific website ONLY?

Thank you.

1 Answer 1

2

To assign the product to a specific website you cannot use the default endpoint, using this endpoint "https://example.com/rest/V1/products" will assign the product to the default website and the website "4" as well, But if you want to assign the product only to a specific website you have to use this endpoint

https://example.com/rest/{default store view for website id 4}/V1/products

please see the attached image

enter image description here

This is an example endpoint

https://example.com/rest/storev2/V1/products

I Hope this will help you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.