Blog • Developer

Unlocking Your Moltin data with Flows

Last updated: 24 Jun 2019

This information is specific to the deprecated version one. For more up-to-date details, see: The power of Flows or visit our Developer Portal.

So, you might be thinking that because your data is stored with us you have only a limited control over its structure. This isn’t the case with Moltin. The underlying infrastructure has been built in such a way that Moltin allows you to control almost everything. We call it “Flows”, and it truly opens up your data structure.

Flows is essentially an EAV system and nearly everything on Moltin runs on top of this. This means you have more flexibility and control over your data out of the box than you get with other eCommerce platforms. You can add flows, fields, and entries to anything you can imagine. For example you could create a Flow for your site or app content that you could then distribute from anywhere. Or you could even add additional data to core components of the Moltin platform.

So What is an EAV system?

Wikipedia defines EAV as: “Entity–attribute–value model (EAV) is a data model to describe entities where the number of attributes (properties, parameters) that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest. In mathematics, this model is known as a sparse matrix.”

For Moltin, this means that any Flow can have any number of fields attached, from a range of available field types and can store a huge number of entries whilst remaining lightning fast to query. You can think of a Flow as a container and is in some ways similar to a database table.

Flows in Practice

Flows might seem like something quite complicated but once you’ve tried it out for yourself you’ll see just how easy it is to use. If you’d rather just create the flows, fields, and entries without touching any code however you can do so via the store management dashboard through simple forms. If interacting with Flows directly gets you excited then you’ll be interested in some simple examples below to help you get started. The code examples assume you are using PHP, other language examples will be available in our documentation.

Creating a Flow

The first thing you need to do when defining your own custom data is to define the container to store it in - a Flow. This is relatively simple, it’s just the title, a slug, and a description. Adding a Flow looks like this:

  $flow = $moltin->createFlow(array(
'name' => 'My Awesome Flow',
'slug' => 'my-awesome-flow',
'info' => 'This flow stores my awesome custom data'

Adding Fields to a Flow

So we’ve created a Flow, now we need to define our fields. A simple string field can easily be added like this:

  $field = $moltin->post('flow/my-awesome-flow/field', array(
'slug'     => "title",
'name'     => "Title",
'type'     => "string",
'options'  => [],    // optional
'required' => false, // optional
'unique'   => false, // optional
'title'    => true   // optional

Other field types can be added including; choice, country, date, decimal, email, integer, relationship, slug, string, text, multiple, tax band, gateway, and currency. Whilst some of these are self explanatory, there are a couple of interesting ones here. The multiple and relationship field types allow you to bind the field to a particular flow, meaning the field will return the available entries from that flow. You can see an example below of creating a relationship field between “my-awesome-flow” and the categories flow.

  $field = $moltin->post('flow/my-awesome-flow/field', array(
'slug'     => "category",
'name'     => "Category",
'type'     => "relationship",
'options'  => ['relates_to' => 'categories'],
'required' => false, // optional
'unique'   => false, // optional
'title'    => false  // optional

You can also edit most of the core Moltin system by adding your own fields, allowing you to adapt the platform to your needs with ease. You would just replace “my-awesome-flow” with the core flow slug e.g. “categories” or “products”.

Adding Entries to a Flow

The Flow and fields are set, now it’s just a case of adding your entries so that you can retrieve and perform further operations later.

  $entry = $moltin->post('flow/my-awesome-flow/entry', array(
'title'     => "Entry Title",
'category'  => 1    

Getting Entries from a Flow

Retrieving entries that you have added to a Flow is relatively straightforward, an example is shown below to retrieve the first 15 entries.

  $entries = $moltin->get('flow/my-awesome-flow/entries', ['limit' => 15, 'offset' => 0]);

So now what?

Flows is an incredibly powerful tool, but when combined with the Moltin API, it enables you to create and store any data you can think of and distribute it to where ever you need it. Flows and the API remove the barriers and hurdles that developers face when extending a platform with custom data.

Custom Data Structure Dashboard

Manage your data structure through the store management dashboard

So now you know what Flows is and how it works your only limitation is your imagination. You can read more in-depth and detailed instructions and examples over on the docs, create and edit your own Flows via the store management dashboard or dive straight in and start implementing Flows programmatically into your own projects.

Over the coming weeks, we’ll be giving a sneak preview of some of the tech we’ve been working on, including a preview of the next version of our store management dashboard (powered by AngularJS), an awesome new template system and some great example uses of Flows. If you have any uses for Flows drop us a message or leave a comment below, we’d love to hear your ideas!

The Moltin team

Save Your Seat! Magento Migration Considerations

Discover best practices for migrating off of M1 from a Magento certified partner and decide if M2 is right for you.

From Our Blog

20 Jun 2019

Analytics for your Moltin store

Today we’re going to take a look at how to use best-in-class data warehousing and analytics solutions on top of Moltin, specifically in relation to orders and order items.

Read More
Matt Foyle
9 min. read in Developer
19 Jun 2019

Further Flows improvements

We've been working hard recently to improve the developer experience when using the Moltin API to build an online store.

Read More
James Owers
9 min. read in Announcements | Developer
29 May 2019

What to consider when migrating eCommerce platforms

Even though you are well aware of the pitfalls of your current eCommerce platform - be it rigidity, technical debt or the inability to innovate quickly; the thought of re-platforming can be a scary...

Read More
Joanna Suau
9 min. read in Magento Migration | Developer | eCommerce