1

I have a sample CSV to test bulk import is feasible before we try it with the real CSV which contains 12000 items. example of the test csv file

I've imported the sample using FeedMe but the only unique identifier is 'Model'. This results in many duplicate titles because FeedMe just iterates over the rows.

Ideally we want some kind of categorisation where a 'Make is defined and then all other 'make' references are nested under the first...

  • AC Petite

    • 346 -- CC, Country, Year etc
    • 353 -- CC, Country, Year etc
  • Adler

    • M100 -- CC, Country, Year etc
    • MR100 -- CC, Country, Year etc
    • M150 -- CC, Country, Year etc
    • MB150 -- CC, Country, Year etc

etc...

Ultimately we're trying to create a "Motorbike Chain Finder". Where a user will: 1. Select their Make (AC Petite, Adler, Triumph etc...) 2. Select their Model or their CC

The process will then display the chain type (pitch) which will fit their bike.

I'm looking for help/guidance on the best way to set up Craft (Section/Fields) so the imported data can be queried as described above.

For example, is there a way to auto categorise based on 'Make' or is there a way to maybe do this after the initial import?

I'm not even sure i'm asking the question correctly but any help is appreciated.

2
  • 1
    You could import all of the Makes as categories first, then attach that category when you import all of the Models.
    – Joshua M
    Commented Feb 20, 2020 at 12:55
  • Thanks Joshua M but I don't understand what you mean? As you suggest I have re-imported and created new categories using the 'Make' column. I then created a Category field attached to my Category Group and added it to the Entry Type. I then created a new Feed (same csv) to import the Models as Entries but the Category Field is not available to map to?
    – Martin
    Commented Feb 20, 2020 at 15:16

2 Answers 2

1

The nested/hierarchical presentation you're suggesting is perfectly fine for the front end presentation, but you don't want to permanently store your data that way in the back end as it's too rigid and doesn't reflect the fundamental content data model, which in turn makes everything you want to do with the data (such as filtering/searching/sorting) a bit harder.

I'm sure there are lots of different approaches, but for maximum flexibility, if it were me, I would run a few imports consecutively:

  1. Import all the "Makes" into a dedicated section
  2. Import all the "Countries" into a dedicated category group or section (bear in mind that categories as a concept is rumoured to be going away in Craft 4).

...these first two steps give your editors the flexibility to add/edit/remove Makes and Countries in future - do the same with any other columns you think should be treated that way... the decision would depend on how many items you expect there to be, how often they might require editing, whether they should be searchable/filterable, and to what extent the data should be arbitrary or pre-defined. (For example, the CC rating could be imported into another category group or a simple dropdown field of pre-defined values, whereas the 'Act CC' (Actual CC?) rating would more likely be a plain text field to cater for any arbitrary value).

  1. Import everything else into a dedicated section (maybe called "Products", or "Chains" - Again, "Products" would give you more future flexibility, but you might want to then pre-categorise everything in this import under a new "Chains" category). Use the Model as the title, and create relationships to the Makes and Countries (and whatever other relationships you need). You'd need to decide what fieldtypes to use for the other columns - generally you're best avoiding plain text fields for something like this to maintain future data integrity and make front end searching/filtering consistent.

This is all just fundamental content modelling - It really comes down to how small you want to break things up. Most content modellers err on the side of using highly atomic content and then creating relationships between them, but you can take that concept too far.

1
  • Thanks James, We're actually thinking of putting this out to Freelance as I can't get my head around it and we need to prove concept before client will move onto the next stage.
    – Martin
    Commented Feb 20, 2020 at 15:55
1

I would set an dynamic title for entry titles ie. {make.one().title} - {model}, then have make as a category field, model as a text field.

It doesn't sound like it matters what the entry title is, but this will make it nicer to manage in the back-end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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