Hi,
We’re building a new site based on Storyblok and it needs to contain a product catalogue.
At it’s simplest it would have a component called products which might have a few simple columns like this…
- product_name (text)
- price (number)
- description (textarea)
There will be many more fields than that but you get the idea.
My question is how to add different fields for different types of products. For example any television will have the following
- Screen size (number)
- Display tech (OPtions - LCD, OLED, QLED etc.)
For a full example see here: https://www.currys.co.uk/gbuk/tv-and-home-entertainment/televisions/televisions/301_3002_30002_xx_xx/xx-criteria.html
But a refrigerator might have different options
- Type (text - e.g. freestanding)
- Width (number)
- Brand (text)
Again, see here: https://www.currys.co.uk/gbuk/household-appliances/refrigeration/fridge-freezers/333_3125_30212_xx_xx/xx-criteria.html
So, if I was modelling this in a SQL dabatase I would have a products table with a “product_type_id” column which would link to a product types table (ideally many to many). The product_types table would contain the name of the product type and then there would be another table full of facets (or options), each with a name and type, like this…
product_types
id (e.g. 123)
name (e.g. televisions)
product_type_options
id (e.g. 999)
product_type_id (e.g. 123 for televisions)
name (e.g. screen size)
type (e.g. integer)
Then there would be a table which has the options for each product…
product_options
id
product_id (links to actual product)
product_type_option_id (e.g. 999 for screen size)
value (e.g. 55)
So, the question is how to model this in Storyblok? In an ideal world the editor would enter a product and be able to choose the product type from a drop down list. If they choose Televisions then they would see new questions below that showing all the “product_type_options” for televisions.
Obviously, if that isn’t possible then we could just have a very long list of option for each product with every possible option on it but that would be difficult for the site editor.
Once it’s modeled I would also need to know how to retrieve all the options and values for each product type to make the UI for the filters and how to do a query like “fetch all products which are televisions and have a screen size over 55 inches”. However, we will probably be copying all records to Algolia so may be doing all the retrieval/searching through Algolia.
I realise this is a lot of info for one question and it’s probably pushing the limits of Storyblok but I thought I’d ask on here before tackling the problem because I’m probably not the first person to attempt it.