Vendure - Setting up facets
I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...
I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

As mentioned in my very first article about Vendure, one of the most important things for me was the concept of facets.
In my use case, I needed custom elements for each product that the end users could filter.
For example, the beer shop I'm working on needs to have quite a lot of global fields:
Luckily for us, Vendure supported this out of the box, and in this article, I'll show you how to set it up.
Note: This involves more graphical interaction over development.
You can spool up your Vendure server and visit the admin UI at http://localhost:3000/admin/.
Move to Facets in the left sidebar menu; if you opt for the demo products, you'll see some already created facets.

In the top right, you'll have the option to create new facets containing a name and optional code. Once you've chosen a name, you'll be able to add facet values. These are all the unique values for that facet.
I've created a Test facet with foo and bar values in the example below.

This is all great and well, but it doesn't do much. So we must move to one of our products to leverage these facets.
When you open a product, you should see on the right side there is a button to add facets. The important part to note here is that it searches based on the values, not the name.
I'm trying to add the Foo value in this case.

As mentioned in the Vendure import article, we can use an import to manage many products.
It's good to note that this also supports the import of facets!
How it works is that you define variantFacets as a column, and inside, you can column deliminate all the values like so:
test:Foo|test:Bar
This would add both the Foo and the Bar value.
The test part is the code of the facet that we created.
This is super helpful in creating an excellent structured database with all my products organized with custom facets.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter