2

On Magento 2.4.6:

When our ERP executes an API request on the PUT method /all/V1/product/:sku with the following JSON content:

{
  "product": {
    "custom_attributes": [
      {
        "attribute_code": "delais",
        "value": "30"
      }
    ]
  }
}

Another attribute, warranty_type, also gets updated (its value becomes null) on this product, leading to the loss of information stored in this attribute, even though I did not request this update.

Furthermore, if I attempt to set warranty_type in the custom_attributes during the request submission, it does not seem to update and remains null instead of changing to standard.

Attribute configuration :

        $eavSetup->addAttribute(
            Product::ENTITY,
            ProductAttributeInterface::WARRANTY_TYPE,
            [
                'type' => 'varchar',
                'label' => 'Warranty type',
                'input' => 'select',
                'source' => WarrantyType::class,
                'required' => false,
                'sort_order' => 30,
                'global' => ScopedAttributeInterface::SCOPE_STORE,
                'group' => 'General',
                'visible' => true,
                'user_defined' => true,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'unique' => false,
                'apply_to' => '',
                'backend' => ArrayBackend::class,
                'is_used_in_grid' => false,
                'is_visible_in_grid' => false,
                'is_filterable_in_grid' => false,
            ]
        );

Note : on Mage 2.4.5, this work correctly

Thanks

0

1 Answer 1

0

I solved my problem. It was due to the definition of 'backend' => ArrayBackend::class, while it is a string and not an array. By removing it, everything went back to normal.

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.