landofcoder / module-product-reviews-graphql
Magento 2 高级产品评论 GraphQl 扩展
1.0.4
2022-08-06 05:07 UTC
Requires
This package is auto-updated.
Last update: 2024-09-06 10:15:10 UTC
README
landofcoder/module-product-reviews-graphql
主要功能
magento 2 产品评论 GraphQl 扩展
安装
* = 在生产环境中请使用 --keep-generated
选项
类型 1: 压缩文件
- 将压缩文件解压到
app/code/Lof
- 通过运行
php bin/magento module:enable Lof_ProductReviewsGraphQl
启用模块 - 通过运行
php bin/magento setup:upgrade
应用数据库更新* - 通过运行
php bin/magento cache:flush
清除缓存
类型 2: Composer
- 将模块添加到 composer 仓库中,例如
- 私有仓库
repo.magento.com
- 公共仓库
packagist.org
- 公共 GitHub 仓库作为 vcs
- 私有仓库
- 通过运行
composer config repositories.repo.magento.com composer https://repo.magento.com/
将 composer 仓库添加到配置中 - 通过运行
composer require landofcoder/module-product-reviews-graphql
安装模块 composer - 通过运行
php bin/magento module:enable Lof_ProductReviewsGraphQl
启用模块 - 通过运行
php bin/magento setup:upgrade
应用数据库更新* - 通过运行
php bin/magento cache:flush
清除缓存
待办事项
查询
- 查询获取产品高级评论
- $urlKey : String - 产品 URL 键
- $search : String - 通过关键字过滤
- $pageSize : Int = 20 - 页大小
- $currentPage : Int = 1 - 当前页
- $sortBy : ReviewSortingType = default - 枚举: default, helpful, rating, latest, oldest, recommended, verified
query {
products(filter: { url_key: { eq: $urlKey } }) {
items {
id
uid
sku
advreview (
search: $search
pageSize: $pageSize
currentPage: $currentPage
sortBy: $sortBy
) {
__typename
totalRecords
ratingSummary
ratingSummaryValue
recomendedPercent
totalRecordsFiltered
detailedSummary {
__typename
one
two
three
four
five
}
items {
__typename
review_id
created_at
answer
verified_buyer
is_recommended
detail_id
title
detail
nickname
like_about
not_like_about
guest_email
plus_review
minus_review
report_abuse
rating_votes {
__typename
vote_id
option_id
rating_id
review_id
percent
value
rating_code
}
images {
__typename
full_path
resized_path
}
comments {
__typename
id
review_id
status
message
nickname
email
created_at
updated_at
}
}
}
}
}
}
示例
query {
products(filter: { url_key: { eq: "pp-009238562599" } }) {
items {
id
uid
advreview (
search: ""
pageSize: 10
currentPage: 1
sortBy: helpful
) {
__typename
totalRecords
ratingSummary
ratingSummaryValue
recomendedPercent
totalRecordsFiltered
detailedSummary {
__typename
one
two
three
four
five
}
items {
__typename
review_id
created_at
answer
verified_buyer
is_recommended
detail_id
title
detail
nickname
like_about
not_like_about
guest_email
plus_review
minus_review
report_abuse
rating_votes {
__typename
vote_id
option_id
rating_id
review_id
percent
value
rating_code
}
images {
__typename
full_path
resized_path
}
comments {
__typename
id
review_id
status
message
nickname
email
created_at
updated_at
}
}
}
}
}
}
- 查询评论的评论
query {
comments (
review_id: Int!
filter: ReviewCommentFilterInput
pageSize: Int = 5
currentPage: Int = 1
sort: ReviewCommentSortInput
) {
items {
__typename
id
review_id
status
message
nickname
email
parent_id
created_at
updated_at
}
total_count
page_info {
page_size
current_page
total_pages
}
}
}
- 突变 提交喜欢评论
mutation {
likeReview (review_id : Int!)
}
- 突变 提交不喜欢评论
mutation {
unlikeReview (review_id : Int!)
}
- 突变 提交报告评论
mutation {
reportReview (review_id : Int!)
}
- 突变 提交带有额外信息的评论
mutation {
createProductAdvReview (
input: {
sku: String!
nickname: String!
summary: String!
text: String!
ratings: [ProductAdvReviewRatingInput!]!
email: String
advantages: String
disadvantages: String
images: [ReviewGalleryImageInput]
}
) {
review {
review_id
created_at
answer
verified_buyer
is_recommended
detail_id
title
detail
nickname
like_about
not_like_about
guest_email
plus_review
minus_review
report_abuse
rating_votes {
__typename
vote_id
option_id
rating_id
review_id
percent
value
rating_code
}
images {
__typename
full_path
resized_path
}
comments {
__typename
id
review_id
status
message
nickname
email
created_at
updated_at
}
}
}
}
- ProductAdvReviewRatingInput
input ProductAdvReviewRatingInput {
rating_id: Int
rating_name: String!
value: Int!
}
rating_name: A Rating Name: 它是表 rating 中的 rating_code。示例 默认 rating_name: 质量,价值,价格,评级价值:一个评级数字,从 1 到 5。
- ReviewGalleryImageInput
input ReviewGalleryImageInput {
src: String
}
- 突变 发布评论
mutation {
createComment (
input : {
review_id: Int!
title: String
message: String!
nickname: String
email: String
parent_id: Int
website: String
}
) {
comment {
id
review_id
status
message
nickname
email
created_at
updated_at
}
}
}
示例
mutation {
createComment (
input: {
review_id: 348,
title: "Comment Title Graphql",
message: "New message for review from Graphql",
nickname: "Test User",
email: "testuser@gmail.com"
}
) {
comment {
id
review_id
status
message
nickname
email
created_at
updated_at
}
}
}
- 获取登录客户的评论
查询
{
customer {
advreviews(
filter: {
}
pageSize: 5
currentPage: 1
) {
items {
review_id
entity_pk_value
created_at
answer
verified_buyer
is_recommended
detail_id
title
detail
nickname
like_about
not_like_about
guest_email
plus_review
minus_review
report_abuse
rating_votes {
__typename
vote_id
option_id
rating_id
review_id
percent
value
rating_code
}
images {
__typename
full_path
resized_path
}
comments {
__typename
id
review_id
status
message
nickname
email
created_at
updated_at
}
}
page_info {
page_size
current_page
total_pages
}
total_count
}
}
}
过滤字段
review_id
created_at
title
detail
nickname
entity_pk_value
排序字段
review_id
created_at
title
detail
nickname
entity_pk_value