fix: Backend taxonomy API response format mismatch
Problem: Frontend expects term_id but backend returns id, causing undefined in update/delete URLs Changes: 1. Categories GET endpoint: Changed 'id' to 'term_id', added 'description' field 2. Tags GET endpoint: Changed 'id' to 'term_id', added 'description' field 3. Attributes GET endpoint: Changed 'id' to 'attribute_id', added 'attribute_public' field This ensures backend response matches frontend TypeScript interfaces: - Category interface expects: term_id, name, slug, description, parent, count - Tag interface expects: term_id, name, slug, description, count - Attribute interface expects: attribute_id, attribute_name, attribute_label, etc. Files Modified: - includes/Api/ProductsController.php (get_categories, get_tags, get_attributes) Result: ✅ Update/delete operations now work - IDs are correctly passed in URLs ✅ No more /products/categories/undefined errors
This commit is contained in:
@@ -575,9 +575,10 @@ class ProductsController {
|
||||
$categories = [];
|
||||
foreach ($terms as $term) {
|
||||
$categories[] = [
|
||||
'id' => $term->term_id,
|
||||
'term_id' => $term->term_id,
|
||||
'name' => $term->name,
|
||||
'slug' => $term->slug,
|
||||
'description' => $term->description,
|
||||
'parent' => $term->parent,
|
||||
'count' => $term->count,
|
||||
];
|
||||
@@ -602,9 +603,10 @@ class ProductsController {
|
||||
$tags = [];
|
||||
foreach ($terms as $term) {
|
||||
$tags[] = [
|
||||
'id' => $term->term_id,
|
||||
'term_id' => $term->term_id,
|
||||
'name' => $term->name,
|
||||
'slug' => $term->slug,
|
||||
'description' => $term->description,
|
||||
'count' => $term->count,
|
||||
];
|
||||
}
|
||||
@@ -621,11 +623,12 @@ class ProductsController {
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
$result[] = [
|
||||
'id' => $attribute->attribute_id,
|
||||
'name' => $attribute->attribute_name,
|
||||
'label' => $attribute->attribute_label,
|
||||
'type' => $attribute->attribute_type,
|
||||
'orderby' => $attribute->attribute_orderby,
|
||||
'attribute_id' => $attribute->attribute_id,
|
||||
'attribute_name' => $attribute->attribute_name,
|
||||
'attribute_label' => $attribute->attribute_label,
|
||||
'attribute_type' => $attribute->attribute_type,
|
||||
'attribute_orderby' => $attribute->attribute_orderby,
|
||||
'attribute_public' => $attribute->attribute_public,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user