Liquid, JavaScript, themes, sales channels
This is quite a head-scratcher.
I'm building an e-commerce website for a bookstore. A product (i.e. a book) has additional fields. One such field is the "author". An author can have multiple books. A book can also have multiple authors. Essentially, it's a many-to-many relationship in a relational database system.
When a user clicks on a book, it should display all of the book's authors. An individual author should have a clickable link to see other books (products) written by the same author.
Images attached for better explanation.
How can I produce this many-to-many relationship in my Shopify storefront? This seems like a very common scenario for a typical online store. I would be VERY surprised if Shopify couldn't handle the above mentioned use case.
I have the same question. Any insights on this topic?
Hi @Rouz ! You can do it using Tags.
Hi Cristina, thanx for your comment. It was really useful.
Now our products have (besides authors) also other many-to-many relations. So since tags would be used to store authors, are there any other fields I could use for the other relations?
Hi Rouz,
If you'd like to attach a list of values to a product, you'd have to create a custom field: text as a list custom field type.
The only problem with custom fields is that they are not searchable or linkable.
Thank you.
The fields not being searchable or linkable indeed is a problem.
We need the same kind of behavior like we had with the authors.
I wonder if there is a solution?
I heard you could create an app that stores these kind of relations in the database. But then I don't know if and how it is possible to pass the data to the frontend, as you don't want to make 2 different requests
Hi Rouz,
I'm not sure if there is a good solution other than using tags.
But a workaround could be to store the list of values as comma separated values in the vendor or product type fields (which are linkable and searchable): for example "value1,value2,value3". Then split these values using custom liquid code when displaying them on the storefront.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024