I have a functionality where I have to display the bestseller products, so for this I am using Product query.
To full fill my requirement I am using one custom short attribute
products(
search: "",
sort: {trending: DESC},
pageSize: ${params.limit ?? 12},
currentPage: ${params.page}
)
In Magento I have create a module which in which I am adding ProductAttributeSortInput
in etc/schema.graphql
input ProductAttributeSortInput {
trending: SortEnum! @doc(description: "Sort by trending products")
}
After running my code I am getting below error –
Field "trending" is not defined by type ProductAttributeSortInput
What I am doing wrong in this?
Or if you can share any sample using which I can get the bestseller products from Magento 2 using graphQl query.
Thanks in advance!!