Moltin type and its members



Hello there,

I just started using moltin and I was looking for some guidance regarding the Moltin type and its members.

I’m not exactly a coding pro so can you use a simple language to a fair extent?

Anyway, I tried to use the example which moltin specifies in the getting started with moltin for swift but I got the error (Type ‘Moltin’ has no member ‘products’) and when I tried to edit it like swift recommended I got the next error (Value of type ‘ProductRequest’ has no member ‘all’)

Any ideas on how to solve this?



Hi amrmagdy,

i assume you are using v2 of the SDK for Swift.

Moltin.product has no function called all().

Instead you have following options:

  1. Find a list of products by using Moltin.product.list(…)

  2. Find one single Product by using Moltin.product.get(…)

     //Products with a (example) Query
     let query = MoltinQuery(offset: nil, limit: nil, sort: nil, filter: nil, include: [.products, .collections])
     Moltin.product.list(withQuery: query) { (result) in
         switch result {
         case .failure(let error):
         case .success(let productList):
             print("I could find \(productList.products.count) products!")
             for product in productList.products{
                 print("product with name: \( in productList.")
     //Products without a Query (i did not test this one):
     Moltin.product.list { (result) in
         switch result{
         case .failure(error: let error):
             print("error: \(error)")
         case .success(result: let productList):
             print("Here are the products: \(productList.products)")
             if let meta = productList.meta{
                 print("Here is the ProductList Meta: \(meta)")
     //Find a single product by id:
     Moltin.product.get(withProductID: "yourProductId") { (result) in
         switch result{
         case .failure(error: let error):
             print("Oh, i could not find a product with this \(error)")
         case .success(result: let product):
             if let myProduct = product{
                 print("I could find a product with the name: \(")


Thanks Daniel for your reply.
I tried your code samples and they were all working perfectly but then I decided to update to xcode 9.1
I did update the pod files but now the app won’t rebuild.
I should try and find what these issues are about
Still thankful for your help.