OK, enough theory, let’s do something hands-on. I just noticed that I’m missing something from my Convenience app. I want to sell not only products but services as well.
The thing is, that in my store I have a counter for a locksmith who cuts keys, fixes broken locks and such.
I’m going to store the services in my Products catalog, but I need a way of telling a product from a service. So, I’m going to add a new ProductType attribute here. The question is: what data type should this attribute have?
This should be the list prefilled with only two values: Product and Service, and I don’t want users to be able to change it, right? This is exactly what we use Enumerations for.
Let me show you how it’s done.
I’m gonna add a new Enumeration called ProductTypes and fill it with the Product and Service values. Then I’m gonna say to the ProductType attribute here that it has to have this exact type.
Let’s check what we’ve got. Here is my Products and now I can tell every one of them who are they - Product or Service.
So, this was a prefilled and fixed list of possible values. What if we need the list that is extendable by a user? For example, I want to specify the brand for every product I have. First of all, I don’t want to store this attribute value as a string, right? Otherwise, I will end up having many different spellings and typos of Pringles and will never filter out products of this brand correctly.
So, I need the list but I cannot use the Enumeration, right? I don’t know all the brands, and even if I did, there would be new ones appearing every day. So, I want users to fill out the list as they go.
This is what we use the catalogs for. Let’s see how we do that.
I’m going to create a new catalog, name it Brands, and say to the Brand attribute that this is its type from now on.
Now I can fill up this catalog, adding new brands as I go, and referring to this new items from the Products catalog.
Ready to try it yourself?