updateAttribute
Update an existing product attribute, including options and group assignments.
Import
import { updateAttribute } from "@evershop/evershop/catalog/services";
Syntax
updateAttribute(uuid: string, data: AttributeData, context?: Record<string, any>): Promise<Attribute>
Parameters
uuid
Type: string
Attribute UUID to update.
data
Type: AttributeData
Attribute data to update. All fields are optional.
{
attribute_name?: string;
type?: string;
is_required?: boolean;
display_on_frontend?: boolean;
groups?: number[];
options?: { option_text: string, option_id?: string | number }[];
[key: string]: any;
}
context
Type: Record<string, any> (optional)
Context object for hooks.
Return Value
Returns Promise<Attribute> with updated attribute data.
Examples
Update Name
import { updateAttribute } from "@evershop/evershop/catalog/services";
await updateAttribute('attribute-uuid-123', {
attribute_name: "Updated Name"
});
See Also
- createAttribute - Create attribute
- deleteAttribute - Delete attribute