mageworx / module-seoxtemplates-graph-ql
N/A
2.0.0
2022-04-12 21:29 UTC
Requires
- magento/module-catalog-graph-ql: >= 100.3.1 < 101
- magento/module-cms-graph-ql: >= 100.3.1 < 101
- mageworx/module-seoxtemplates: >= 2.13.8
This package is auto-updated.
Last update: 2024-09-05 12:41:19 UTC
README
为Mageworx Magento 2 SEO Suite Ultimate 扩展插件提供的GraphQL API模块。
安装
1) 复制粘贴方法
- 下载此模块并将其上传到
app/code/MageWorx/SeoXTemplatesGraphQl
目录 (如果不存在,请先创建"SeoXTemplatesGraphQl"目录)
2) 使用composer(从packagist)安装
- 执行以下命令:
composer require mageworx/module-seoxtemplates-graph-ql
如何使用
分类查询示例
在"Bags[ - 过滤器: {filter_all}]"中设置的"所有分类SEO属性"(元标题,元描述等)query GetCategories($id: String!, $pageSize: Int!, $currentPage: Int!, $filters: ProductAttributeFilterInput!, $sort: ProductAttributeSortInput) { categories(filters: {ids: {in: [$id]}}) { items { uid ...CategoryFragment } } products(pageSize: $pageSize, currentPage: $currentPage, filter: $filters, sort: $sort) { ...ProductsFragment mw_seo_category_data { meta_title meta_description meta_keywords category_seo_name } } } fragment CategoryFragment on CategoryTree { uid meta_title meta_keywords meta_description category_seo_name } fragment ProductsFragment on Products { items { id uid name sku url_key } page_info { total_pages } total_count }
查询变量
{ "currentPage": 1, "id": "4", "filters": { "color": { "eq": "49" }, "category_id": { "eq": "4" } }, "pageSize": 1, "sort": { "position": "ASC" } }
答案
{ "data": { "categories": { "items": [ { "uid": "NA==", "meta_title": "Bags", "meta_keywords": "Bags", "meta_description": "Bags", "category_seo_name": "Bags" } ] }, "products": { "items": [ { "id": 7, "uid": "Nw==", "name": "Impulse Duffle", "sku": "24-UB02", "url_key": "impulse-duffle" } ], "page_info": { "total_pages": 4 }, "total_count": 4, "mw_seo_category_data": { "meta_title": "Bags - Filters: Color: Black", "meta_description": "Bags - Filters: Color: Black", "meta_keywords": "Bags - Filters: Color: Black", "category_seo_name": "Bags - Filters: Color: Black" } } } }
产品查询示例
在"Wayfarer Messenger Bag[ in {categories}]"中设置的"所有产品SEO属性"(元标题,元描述等)
query getProductDetailForProductPage($urlKey: String!) { products(filter: {url_key: {eq: $urlKey}}) { items { id uid ...ProductDetailsFragment } } } fragment ProductDetailsFragment on ProductInterface { categories { uid breadcrumbs { category_uid } } id uid meta_title meta_description meta_keyword product_seo_name name sku url_key ... on ConfigurableProduct { configurable_options { attribute_code attribute_id uid label values { uid default_label label store_label use_default_value } } variants { attributes { code value_index } product { uid media_gallery_entries { uid disabled file label position } sku stock_status } } } }
查询变量
{ "currentPage": 1, "id": "4", "filters": { "color": { "eq": "49" }, "category_id": { "eq": "4" } }, "pageSize": 1, "sort": { "position": "ASC" } }
答案
{ "data": { "products": { "items": [ { "id": 4, "uid": "NA==", "categories": [ { "uid": "Mw==", "breadcrumbs": null }, { "uid": "NA==", "breadcrumbs": [ { "category_uid": "Mw==" } ] }, { "uid": "Nw==", "breadcrumbs": null }, { "uid": "OA==", "breadcrumbs": null } ], "meta_title": "Wayfarer Messenger Bag", "meta_description": "Wayfarer Messenger Bag", "meta_keyword": "Wayfarer Messenger Bag", "product_seo_name": "Wayfarer Messenger Bag", "name": "Wayfarer Messenger Bag", "sku": "24-MB05", "url_key": "wayfarer-messenger-bag" } ] } } }