getEvent()->getProduct(); $controller = $observer->getEvent()->getController(); if (!$product instanceof Product || $product->getTypeId() !== Configurable::TYPE_CODE || !$controller ) { return; } $post = $controller->getRequest()->getPostValue(); $productData = is_array($post['product'] ?? null) ? $post['product'] : []; $attributeCode = AddMixStepPricesAttribute::ATTRIBUTE_CODE; if (!array_key_exists($attributeCode, $productData)) { return; } $value = $this->unwrapNestedValue($productData[$attributeCode], $attributeCode); $attribute = $product->getResource()->getAttribute($attributeCode); if (!$attribute) { return; } $product->setData($attributeCode, is_array($value) ? $value : []); $attribute->getBackend()->beforeSave($product); $product->getResource()->saveAttribute($product, $attributeCode); } private function unwrapNestedValue(mixed $value, string $attributeCode): mixed { if (is_array($value) && isset($value[$attributeCode]) && is_array($value[$attributeCode])) { return $value[$attributeCode]; } return $value; } }