我将shopify实施到ios应用中。到目前为止,我已经能够获得我的产品。我正在使用移动团购SDK库。 我如何设法从产品中获得单个信息,例如标题或说明。 到目前为止,我只获得了整个产品,看起来像:
[产品:[“ totalInventory”:null,“描述”:Tolles TShirt,“ id”:Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQNzUzMzUxMTQ4ODY =,“ productType”:,“ title”:Tee],产品:[“ deproductType”: :,“ id”:Z2lkOi8vc2hvcGlmeS9Qcm9dWN0LzQ0NzIwMDMyMzE4Nzg =,“ totalInventory”:,“ title”:连帽衫]]
func findProducts(){
let query = Storefront.buildQuery { $0
.shop { $0
.collections(first: 10) { $0
.edges { $0
.node { $0
.id()
.title()
.products(first: 10) { $0
.edges { $0
.node { $0
.id()
.title()
.totalInventory()
.productType()
.description()
}
}
}
}
}
}
}
}
let client = Graph.Client(shopDomain: "online-app-store.myshopify.com", apiKey: "d63e690cf2dea787e9677c03979eb5ba")
client.cachePolicy = .cacheFirst(expireIn: 3600)
let task = client.queryGraphWith(query) { response, error in
let collections = response?.shop.collections.edges.map { $0.node }
collections?.forEach { collection in
let products = collection.products.edges.map { $0.node }
print("products found \(products)")
let name =
let description ??
let id = ??
self.data.append(all(id: "hi", name: "hi", description: collection.products.edges.description))
print(self.data)
}
}
task.resume()
}