Listing Product Categories and and products within



I want to design a food menu which lists all product categories and their products within, so like chip(category) then large chip, small chip, burger(category) chicken, beef etc. Its for an iOS mobile application.


Hey Shannon,

That sounds really cool. My first thought would be to us Product relationships. Check out the API documentation for creating category relationships ( I have been working on some swift stuff so I will take a look at this use case now.



Hey Shannon,

Did some more digging and seems this can more easily be done using .include. I set up a collection and a product for this example (see attached).

I then used included on the product level, you could also use it on the category level
Collection with products
self.request = self.moltin.collection.include([.products]).all { (response) in switch response { case .success(let collection): print( case .failure(let error): print(error) } }
Product with collection
self.request = self.moltin.product.include([.collections]).all { (response) in switch response { case .success(let products): print( case .failure(let error): print(error) } }


Hi George,
I really appreciate the help!! I have one query

Can I specify which products to display within each collection dependant on the category also?
An example,

There are two food menus; Breakfast and Lunch, each with their own collections, so chips, burgers etc and within these collections are the relevant products.

So I want to display all food products linked to the Chips collection within the Lunch Category?

Thanks, Shannon


Hey Shannon,

Yes, you can. You just add the category in the include.

        self.request = self.moltin.product.include([.collections, .categories]).all { (response) in
        switch response {
        case .success(let collection):
        case .failure(let error):




I was discussing previously how to retrieve data from various categories/collections within the molten store. I have successfully implemented this, but am having ongoing issues trying to input this data to a drop down tableview controller. Can you shed light to this, or discuss how you would implement such?

I am able to implement a tableview controller easily, but when attempting to add section headings and getting these to display correctly is where my issue lies.



Hey Shannon,

Not sure exactly what you want to use for the drop down filter. Can you share any code you have started. Are you looking to have a table view with headers? Example
Or just one category at a time? Found this tutorial this does a good job showing similar table view that you may use (skip right to Coding the Meals Table).



This is my code whilst playing about with sections within a tableview controller. I understand the concept when I create my own arrays and have each array input named section with an expanded false value, but I’m unsure how this would work with molten product arrays. I have attached an image of my code.



when I run this code, this is its output. I am happy how this looks, I just need the correct data input.


You can use the sdk to get the categories and the products. You can use an array to use them to populate the tables.

In the top of the class
var categories: [moltin.Category] = []

In the view did load grab the data
self.moltin.category.include([.products]).all { (result: Result<PaginatedResponse<[moltin.Category]>>) in
switch result {
case .success(let response):
self.categories = ?? []
DispatchQueue.main.async {
case .failure(let error):

Then in the tableView
let category = self.categories[indexPath.row]
let products = self.categories[indexPath.row].products

Then for the the label

And for the products



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.