magento2: REST API : Save Product Detail per store view not working

Steps to reproduce

  1. Install Magento from 2.1 branch.
  2. Deploy Sample Data
  3. Using REST API catalogProductRepositoryV1 REF: http://devdocs.magento.com/swagger/index.html

Get Key from Admin token API and use that key in

POST /V1/products PUT /V1/products/{sku} with parameter tried with both parameter one by one

  • store_id=0
  • storeId=0 using following JSON
{
    "saveOptions": "true",
    "product": {
        "name": "Test11_11",
        "sku": "TESTOPP_111",
        "attributeSetId": "15",
        "price": "10",
        "weight": "10",
        "status": "1",
        "visibility": "3",
        "customAttributes": [
            {
                "attributeCode": "manufacturer",
                "value": "222"
            },
             {
                "attributeCode": "store_id",
                "value": "0"
            },

            {
                "attributeCode": "tax_class_id",
                "value": "0"
            },
            {
                "attributeCode": "specialPrice",
                "value": "10"
            },
            {
                "attributeCode": "description",
                "value": "44332211"
            },
            {
                "attributeCode": "eco_collection",
                "value": "1"
            }
        ],
        "typeId": "simple"
    }
}

Does not support store_id / storeId field , but the information in product does not save to store it save to default Store ID

GET /V1/products has parameter storeId same i had tried with PUT & POST but not working with PUT & POST

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I also can confirm that this is not fixed in 2.1.3.

When I POST a product, all attribute values are saved with store_id = 0; After a second, identical request, some (not all) values are saved on store_id 1. Note that the values that are saved for store_id 1 aren’t event present in my original request!

This is the request:

{
	"product": {
		"sku": "ROCA-ROC-13-L",
		"name": "La Roca Insert White",
		"attribute_set_id": 4,
		"price": 25,
		"visibility": 1,
		"type_id": "simple",
		"custom_attributes": [{
			"attribute_code": "meta_title",
			"value": "La Roca Insert White"
		}, {
			"attribute_code": "meta_keyword",
			"value": "La Roca Insert White"
		}, {
			"attribute_code": "meta_description",
			"value": "La Roca Insert White"
		}]
	}
}

After the second time this request is sent, the following attributes are re-saved for store_id = 1:

  • enabled / status
  • name
  • tax class
  • visibility
  • everything under SEO : url_key, meta keywords, title and description
  • display product options in …

Please, can anyone confirm this bug and reopen this ticket? This behaviour pretty much makes using the REST API pretty frustrating, since you’ll end up with clutter in your database everytime the API is called. Especially when you think you changed a products’ attribute, but then later on discover there was a value on storeview-level that is overriding your changes!

edit:
A workaround currently to make sure it only is updated for store_id = 0 is by using this suggestion and adding all to the URL:

POST http://www.domain.com/rest/all/V1/products

This will give the expected behaviour. However, I still the current behaviour should be considered a bug since doing the same request twice results in different results.

To update product for a store view, you can use rest/store_view_code_not_id/V1/products/sku and then PUT json:

{
	"product": {
		"name": "In english",
		"custom_attributes": [
			{
				"attribute_code": "description",
				"value": "simple description"
			},
			{
				"attribute_code": "short_description",
				"value": "short desc desktription"
			}
		]
	}
}