I've created some custom product attributes with REST API, correctly populated them and assigned values to products.
Everything works fine in dev environment whereas I got difficulties in staging environment, even though values and settings are the same, even in the DB. If, for example, I want to update the value of "is_filterable" option in an existing attribute from the backend, Magento says it saved the attribute correctly, but actually no changes are made.
I've tried to update with a PUT call to REST API with correct values, but I'm able to update only the attribute labels,
This is the json i'm passing to "products/attributes/my_attr"
{"attribute":{"attribute_code":"my_attr","attribute_id":174,"scope":"Global","default_frontend_label":"my_attr","frontend_labels":
[{"store_id":1,"label":"my_attr"}],"frontend_input":"select","is_searchable":true,
"is_visible_in_advanced_search":true,"is_comparable":true,"is_filterable":true}}
And this is the Json response, where you can see it is totally ignoring the values for is_filterable and scope.
{"is_wysiwyg_enabled":false,"is_html_allowed_on_front":false,"used_for_sort_by":
true,"is_filterable":false,"is_filterable_in_search":false,"is_used_in_grid":
true,"is_visible_in_grid":true,"is_filterable_in_grid":true,"position":0,
"apply_to"[], "is_searchable":"0","is_visible_in_advanced_search":"0",
"is_comparable":"0","is_used_for_promo_rules":"0","is_visible_on_front":"0",
"used_in_product_listing":"0","is_visible":true,"scope":"global",
"attribute_id":174,"attribute_code":"taglia","frontend_input":"select",
"entity_type_id":"4","is_required":false,"....
Obviously I've reindexed and cleared caches continuously.
The only way I managed to change those values is directly from the DB. I'm going to try with an extension but I'm not sure to succeed.
I've seen there was an issue that should have been fixed in older Magento versions and actually other attributes work fine.
Any clue?
EDIT: I managed to update values with a REST API request, but still not able to save directly from the backend. This is the updated call (array version)
$data = [
"attribute" => [
"attribute_code" => $my_opt,
"attribute_id" => 173,
"entity_type_id" => 4,
"scope" => "global",
"default_frontend_label" => $my_opt,
"frontend_labels" => [
["store_id" => 1,
"label" => $my_opt ]
],
"frontend_input" => "select",
"is_wysiwyg_enabled" => true,
"is_html_allowed_on_front" => true,
"used_for_sort_by" => true,
"is_filterable" => true,
"is_filterable_in_search" => true,
"is_used_in_grid" => true,
"is_visible_in_grid" => true,
"is_filterable_in_grid" => true,
"position" => 1,
"is_searchable" => true,
"is_visible_in_advanced_search" => true,
"is_comparable" => true,
"is_used_for_promo_rules" => true,
"is_visible_on_front" => true,
"used_in_product_listing" => true,
"is_visible" => true
]
];
EDIT2: Moreover, if I try to update some info from the backend, Magento resets the values of the default view store label to empty and the "use in layered navigation" to "No". Stranger at any try.
EDIT 3 seems like the most possible issue can be caused by duplicated values in these dropdown attributes, but I carefully removed all of them from
eav_attribute_option
eav_attribute_option_value
in the db, but actually removing options only, works from the backend too, whereas the creation of new options is not working