Anonymous
Получите все категории с настраиваемыми атрибутами в Magento 2 REST Api.
Сообщение
Anonymous » 03 авг 2024, 19:15
Я использую rest API Magento 2 для вывода списка всех категорий.
{{production_url}}/index.php/rest/V1/categories < /p>
Он вернет все категории
Код: Выделить всё
{
"id": 2,
"parent_id": 1,
"name": "Default Category",
"is_active": true,
"position": 1,
"level": 1,
"product_count": 0,
"children_data": [{
"id": 3,
"parent_id": 2,
"name": "T-shirts",
"is_active": true,
"position": 1,
"level": 2,
"product_count": 8,
"children_data": []
}, {
"id": 4,
"parent_id": 2,
"name": "Phants",
"is_active": true,
"position": 2,
"level": 2,
"product_count": 0,
"children_data": []
}, {
"id": 5,
"parent_id": 2,
"name": "Chridar",
"is_active": true,
"position": 3,
"level": 2,
"product_count": 0,
"children_data": []
}]
}
Но мне нужны специальные атрибуты для каждой категории в результате. Но теперь мне нужно вызвать приведенный ниже API для получения пользовательских атрибутов.
{{production_url}}/index.php/rest/V1/categories/3
Он вернется,
Код: Выделить всё
{
"id": 3,
"parent_id": 2,
"name": "T-shirts",
"is_active": true,
"position": 1,
"level": 2,
"children": "",
"created_at": "2017-06-02 11:21:16",
"updated_at": "2017-06-02 11:21:16",
"path": "1/2/3",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "description",
"value": "
retest
"
},
{
"attribute_code": "image",
"value": "Screen_Shot_2017-06-16_at_4.06.35_PM.png"
},
{
"attribute_code": "display_mode",
"value": "PRODUCTS"
},
{
"attribute_code": "is_anchor",
"value": "1"
},
{
"attribute_code": "path",
"value": "1/2/3"
},
{
"attribute_code": "children_count",
"value": "0"
},
{
"attribute_code": "custom_use_parent_settings",
"value": "0"
},
{
"attribute_code": "custom_apply_to_products",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "redwine"
},
{
"attribute_code": "url_path",
"value": "redwine"
}
]
}
Предположим, есть
[/b] категории, которым мне нужно позвонить
[/b] API для получения пользовательских атрибутов. Существует ли какой-либо единый API для получения всех атрибутов для всех категорий в одном API?
Подробнее здесь:
https://stackoverflow.com/questions/446 ... 2-rest-api
1722701726
Anonymous
Я использую rest API Magento 2 для вывода списка всех категорий. [b]{{production_url}}/index.php/rest/V1/categories[/b]< /p> Он вернет все категории [code]{ "id": 2, "parent_id": 1, "name": "Default Category", "is_active": true, "position": 1, "level": 1, "product_count": 0, "children_data": [{ "id": 3, "parent_id": 2, "name": "T-shirts", "is_active": true, "position": 1, "level": 2, "product_count": 8, "children_data": [] }, { "id": 4, "parent_id": 2, "name": "Phants", "is_active": true, "position": 2, "level": 2, "product_count": 0, "children_data": [] }, { "id": 5, "parent_id": 2, "name": "Chridar", "is_active": true, "position": 3, "level": 2, "product_count": 0, "children_data": [] }] } [/code] Но мне нужны специальные атрибуты для каждой категории в результате. Но теперь мне нужно вызвать приведенный ниже API для получения пользовательских атрибутов. [b]{{production_url}}/index.php/rest/V1/categories/3[/b] Он вернется, [code]{ "id": 3, "parent_id": 2, "name": "T-shirts", "is_active": true, "position": 1, "level": 2, "children": "", "created_at": "2017-06-02 11:21:16", "updated_at": "2017-06-02 11:21:16", "path": "1/2/3", "available_sort_by": [], "include_in_menu": true, "custom_attributes": [ { "attribute_code": "description", "value": " retest " }, { "attribute_code": "image", "value": "Screen_Shot_2017-06-16_at_4.06.35_PM.png" }, { "attribute_code": "display_mode", "value": "PRODUCTS" }, { "attribute_code": "is_anchor", "value": "1" }, { "attribute_code": "path", "value": "1/2/3" }, { "attribute_code": "children_count", "value": "0" }, { "attribute_code": "custom_use_parent_settings", "value": "0" }, { "attribute_code": "custom_apply_to_products", "value": "0" }, { "attribute_code": "url_key", "value": "redwine" }, { "attribute_code": "url_path", "value": "redwine" } ] } [/code] Предположим, есть [b][code]n[/code][/b] категории, которым мне нужно позвонить [b][code]n[/code][/b] API для получения пользовательских атрибутов. Существует ли какой-либо единый API для получения всех атрибутов для всех категорий в одном API? Подробнее здесь: [url]https://stackoverflow.com/questions/44650978/get-all-categories-with-custom-attributes-in-magento-2-rest-api[/url]