You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The API is not returning the Attribute ID if it existing already. So when you are importing a product via the API and add attributes, you need to know the exact attribute ID.
Describe the solution you'd like
The API should check and return if an attribute is existing or has been created while importing products before.
What we did is first modify the /includes/wc-attribute-function.php and added 2 lines to return the existing attribute_id:
$attribute_id = $wpdb->get_var("select attribute_id from {$wpdb->prefix}woocommerce_attribute_taxonomies where attribute_name='" . $slug . "'");
return new WP_Error( 'invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400, 'resource_id' => $attribute_id ) );
Then, because the API function does not return the "resource_id" we added the following lines in 251:
The requirement of knowing the exact product attribute is intended because you can have a product level attribute as well as a global level attribute which may be different. So if you want to link a global attribute, then it does make sense to have attribute ID as a requirement. I am closing this issue, but feel free to write back if you have questions.
Is your feature request related to a problem? Please describe.
The API is not returning the Attribute ID if it existing already. So when you are importing a product via the API and add attributes, you need to know the exact attribute ID.
Describe the solution you'd like
The API should check and return if an attribute is existing or has been created while importing products before.
What we did is first modify the /includes/wc-attribute-function.php and added 2 lines to return the existing attribute_id:
Then, because the API function does not return the "resource_id" we added the following lines in 251:
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: