0

I am going to build a boat catalog.

  • Boat products x 40
  • Types of product x 3
  • Suppliers of products

I was wondering what the best storage setup?

For boat and suppliers these could be entries and categories, eg:

  • Boats = entries x 40
  • Suppliers = Categories x 9
  • Type = Categories x 3

But does it make more sense to use suppliers as entries fields and relate them to products as 'parents'?

Are there specific template benefits later on that can help steer the decision?

1 Answer 1

1

Craft gives you a lot of options here. I think you're close. The way I'd set it up:

  • Boats (section)
  • Suppliers (section)
  • Boat Type (category)

Then in your boats section, set up a Supplier relational field, and have it relate back to your suppliers section and also a Boat Type relational field, which relates back to that category group.

In this way, on the front end, you can easily filter by boat type or supplier.

Example: on your supplier pages, you can easily get a list of all the boats made by that supplier, just by querying that section like:

{# assume we're on a supplier page #} 

{% set boatsBySupplier = craft.entries.section('boats').relatedTo(entry) %}

{% for theBoat in boatsBySupplier %}
    <h2>{{theBoat}}</h2>
    <p>Model: {{theBoat.modelNumber}}</p>
    ...
{% endfor %}

In terms of templating, there won't be a huge difference if you choose a category over an entry, for example, for your suppliers.

I tend to think of brands (suppliers) as content, thus content belongs in an Entry, not in a taxonomy (category). (Down the road you might want to have more than one supplier type, for example.)

But if your data on suppliers is relatively thin, a category would work just as well. Even then, unlike other CMS, Craft allows you to use custom fields on Categories to add more data. So there's no wrong answer there. In that case, Craft will populate the category variable (and not entry) so just change that and you should be all good.

Not sure what you mean here:

But does it make more sense to use suppliers as entries [fields] and relate them to products as 'parents'?

If you're asking about setting up a structure, and having the top level parent be the supplier and the boat model be a child, I'd steer clear of that. A lot of things can go wrong with that model.

In general, I like to keep data structures as "flat" as possible and create depth with Craft's relationships. But if you're asking about using entries fields to relate your suppliers back to your boats, that's exactly what my example above does.

2
  • Thank you so much for the detailed response. It's good to know my brain is crafting in the right direction. On the latter 'products as parents' - that was poorly worded but intended as entries fields to suppliers. The route thru is clear now.
    – joomkit
    Feb 11, 2016 at 23:10
  • Hi @joomkit! Please consider accepting RitterKnight's answer if it was helpful.
    – Matt Stein
    May 9, 2017 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.