Last month we gave you a brief overview of our EAV system ‘flows’, if you missed it check out the previous blog post first! This week we are going to walk through some potential use cases, including how to add product meta tags and setup simple warehouse locations.
Product Meta Tags
Our core platform is streamlined so that default flows only contain fields that are commonly required (title, id, description etc.). Customisation allows you to add the fields you need without clutter.
moltin products don’t include meta tags by default as they are not always required. In some cases using the existing product title and description as meta tags might be adequate for your needs. However, there are likely to be situations when you need to tailor and control your meta tags, particularly where your website’s SEO is concerned. moltin allows you to create and customize these meta tags with ease, let’s take a look at how this is done.
Adding a meta tag via the dashboard
The easiest way to add a new field to an existing flow is via our dashboard. If you’d rather programmatically add a meta tag field to a product or another flow jump to the API tutorial below!
Login to the dashboard & navigate to the Product flow
As this tutorial covers how to add a new field to the products flow you’ll need to login to the dashboard and navigate to the Flows section under the advanced tab. From the Flows section, you will see a list of the current flows for your store. Click the green manage button on the product flow.
Managing the product fields
You’ll see a list of the current product fields. At the top right you’ll find the “add field” button, click on this.
###Create new field Fill in the form with a title and slug. In this case, we’ll give the field the title of “Meta Title” and the slug of “meta_title”. Next, we need to select the field type, for a simple title the “string” type would suffice. When you’re done hit the submit button.
Adding meta tag information to a product
Now that the “meta title” field has been created you should be able to see it at the bottom of the list of fields for the product flow. Navigate to the create/edit product page and you will notice that the meta title field has automatically been added to the bottom of the form.
Adding a meta tag through the API
This tutorial assumes you already know how to authenticate with the API and uses the moltin PHP SDK. If you’re unsure how to do this then please see the API documentation.
Create a new field
$field = $moltin->post('flow/products/field', array( 'slug' => "meta_title", 'name' => "Meta Title", 'type' => "string", ));
Creating additional fields
To add a meta description you would repeat this process using the “text” field type rather than “string”. Once created these fields are automatically added to the create and edit product form for that individual store.
$field = $moltin->post('flow/products/field', array( 'slug' => "meta_description", 'name' => "Meta Description", 'type' => "text", ));
You can follow this process to add other fields to any flow. Other examples could be separate product description fields for other languages or extending the customer data.
For some larger eCommerce stores with physical products warehouse location, aisle and shelf number are really important so you know where your products are! In this example, we’ll create a new flow to store this location data.
Adding a warehouse location flow through the dashboard
As mentioned previously, managing flows can be completed easily from the dashboard. If you’d rather dive into an API tutorial then skip ahead!
###Create a new “Warehouse Location” flow
Add fields to the new Flow
The new flow should now be at the bottom of the flows list. Navigate to manage this list and begin to add fields to store the relevant data. This could be title, description, address, lat/long, contact details etc…
Creating a relationship field
In this simple example, we’ll assume that a product is only ever stored in one warehouse. To create a select dropdown for a warehouse whilst creating/editing a product we need to add a relationship field to the product flow.
A dropdown should appear in the product edit and create forms to select which warehouse this product is stored in.
This could be extended further with additional flows for aisle, shelf or grid numbers for each warehouse or look-up tables so you can keep track of how many of each product is in a particular warehouse at a given time.
Adding a warehouse location flow through the API
Create a new Flow
1 2 3 4 5
$flow = $moltin->createFlow(array( 'name' => 'Warehouse Locations', 'slug' => 'warehouse_locations', 'info' => 'Flow to store warehouse info.' ));
Add fields you would like to store
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
,,, $name = $moltin->post('flow/warehouse_locations/field', array( 'slug' => "name", 'name' => "Name", 'type' => "string", )); $desc = $moltin->post('flow/warehouse_locations/field', array( 'slug' => "description", 'name' => "Description", 'type' => "text", )); $country $moltin->post('flow/warehouse_locations/field', array( 'slug' => "country", 'name' => "Country", 'type' => "country", 'options' => array('default' => 'GB'), ));
Create a relationship field
1 2 3 4 5 6
$field = $moltin->post('flow/products/field', array( 'slug' => "warehouse", 'name' => "Warehouse", 'type' => "string", 'options' => array('relates_to' => 'warehouse_locations'), ));
So we’ve taken a look at a couple of potential use cases in some detail. These could be extended or adapted to suit your projects needs. Flows doesn’t just stop there though, with infinite possibilities, for data storage and retrieval you could add everything from content management with pages, blog posts & categories through to store locations, mailing lists and more!
Do you have an interesting use case or idea for flows? We’d love to hear from you so get in touch!