0

Im working on api integration between one store of magento2 multi store installation and product db of a client. Our current problem is that part of the items for in our store are duplicated (same sku) with different shops. Which by itself is fine and expected. But we would like to be sure that parent products (eg form default view) are never overwriting our values. Right now this works fine for all values that are set for the product.

Problem starts when for example we create product A for shop TEST_SHOP which is new for the shop and installation, with no description, then 3rd party also adds product A for default view with description. Then our product automatically gets description form new update.

As far as I understand this is caused by use default value check box (it is checked by default for empty values). Can this check box be unchecked from API ?

Thanks

0

I am using 2.2 and see that setting values across different store views is not well documented at all.

The “Use Default Value" checkbox is inferred through the content on each site so cannot be set specifically. If the field or attribute is set at Store View level then if it has content in a specific store view it will unchecked. If it has no content in the store view it will be checked.

To set the content in a specific store view use the pattern: -

rest/{siteView}/V1/products/{sku}

To set it at the highest level ready to inherit use: -

rest/all/V1/products/{sku}

I have found for fields such as “Product Name” setting the value to “null” through the API will unset the field and revert to "Use Default Values" in the admin.

For product attributes (such as content) you will need to omit the attribute from the PUT request in the store view and it will then inherit the value set at the all level.

EDIT - Seems like omitting the custom attribute does not maintain the "Use Default Values". I have a call logged with Magento support on this topic so will hopfully be able to update here.

EDIT TWO - Magento support has highlighted that updating the Custom Attributes should NOT include a name field (even though a GET will return this field). If you update in a store view context without the name field and set the value to null the "Use Default Values" will be restored/maintained: -

PUT /rest/{site_view}/V1/products/{SKU}
{"product" : 
  {
    ...
    "name": null,
    ...
    "custom_attributes": [
    {
      "attribute_code": "short_description",
      "value": null,
    },
    ...
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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