saleor: integrate collections

This commit is contained in:
Zaiste 2021-05-13 13:22:57 +02:00
parent 9ca6c38755
commit f5ec8e17a4
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35
3 changed files with 8 additions and 14 deletions

View File

@ -45,7 +45,7 @@ export const handler: SWRHook<
let edges
if (categoryId) {
edges = data.node?.products?.edges ?? []
edges = data.collection?.products?.edges ?? []
// FIXME @zaiste, no `vendor` in Saleor
// if (brandId) {
// edges = edges.filter(

View File

@ -1,5 +1,5 @@
import { SaleorConfig } from '../api'
import { Collection, CollectionCountableEdge } from '../schema'
import { CollectionCountableEdge } from '../schema'
import { getSiteCollectionsQuery } from './queries/'
export type Category = {

View File

@ -3,21 +3,15 @@ import { productConnection } from './get-all-products-query'
export const getCollectionProductsQuery = /* GraphQL */ `
query getProductsFromCollection(
$categoryId: ID!
$first: Int = 250
$sortKey: ProductCollectionSortKeys = RELEVANCE
$reverse: Boolean = false
$first: Int = 100
$channel: String = "default-channel"
) {
node(id: $categoryId) {
collection(id: $categoryId, channel: $channel) {
id
... on Collection {
products(
first: $first
sortKey: $sortKey
reverse: $reverse
) {
${productConnection}
}
products(first: $first) {
...productConnection
}
}
}
${productConnection}
`