0

I update some features of my products from time to time via the REST API. All property values change periodically for each of my stores and sometimes we turn it into a completely blank record.

For example, in Global Scope, the value of my Special Price attribute is $10, this value comes from Global Scope as it is the same in all my stores. Assuming I have A,B,C stores, I am sending this value as blank in my "C" store because I don't want the discount applied to the product in that store.

Please note that I can do this from the Admin panel. Admin panel allows this.

My Request

https://store.local/rest/de_de/V1/products/product-sku

{"product": {
    "price": 15,
    "custom_attributes": [
        {
            "attribute_code": "special_price",
            "value": null
        }
    ]
}}

Display of current record in panel (incorrect)

Global Scope: Global Scope

Store View (Incorrect) Store View (incorret)

This is what should be Store View - this is what should be

0

1 Answer 1

0

Welcome to the community, İsmail. I've entirely replaced my original answer with this one, preserving the clarifying questions at the bottom for history.

In my testing, it seems you're required to use different REST API endpoints to update special_price depending on whether or not catalog prices are scoped to Global or Website in STORES > Settings > Configuration > CATALOG > Catalog > Price > Catalog Price Scope.

  1. Global. You must update special_price using the products/{sku} endpoint. Since Catalog Price Scope is set globally, this special price will apply to this product across all its websites and store views. You may not update special_price using the products/special-price endpoint, and Magento will throw an error if you try.

  2. Website. You must update the special_price value using the products/special-price endpoint. Enterprise additionally requires you to provide a price_from value as the scheduled starting datetime of the special price, although this is optional in Open Source. You may not update special_price using the products/{sku} endpoint, and Magento will silently fail to update Special Price at any scope if you try.

Since you have multiple stores and your Catalog Price Scope is set to Website, it appears you are required to use the products/special-price endpoint. I recommend you review the REST API docs for this endpoint and try using it instead.


Original Questions:

  1. Which version (including patch tag if applicable) are you running? I recommend including this info in all your Magento questions.
  2. Can you confirm you're using the products/{sku} REST API endpoint? I take product-sku in your question to be equivalent to {sku} in Magento's docs, but it's best to be sure.
  3. What happens if you attempt to null this attribute's value globally? Does it fail in that scope as well, or does it only fail in store scope?
3
  • 1 - I try it in versions 2.4.3 and 2.4.2. ** 2 - Yes! ** 3- Actually, the situation just occurred when I update any custom-attribute it deletes all <null> records for stores from my database (eav tables). For example, in website and store scopes, all the data I entered as null from the panel, when I update any custom attribute (think of it as null data), it deletes it from my database! Commented Apr 10, 2022 at 0:21
  • Thank you, İsmail. I've updated my answer based on further research using your answers as a starting point.
    – kookaburra
    Commented Apr 11, 2022 at 14:49
  • @İsmailÇakır, were you able to solve your problem?
    – kookaburra
    Commented Apr 13, 2022 at 2:08

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.