Roots Discourse

Automotive parts data organization

Not sure if this type of question is allowed here but didn’t want to post on SO to get a bunch of “use a plugin” answers. Feel free to remove if inappropriate.

About to build an auto parts store and realizing that I have a bit of a taxonomy nightmare. Obviously, I have a HUGE amount of automotive categories/sub-categories BUT not sure the best way to implement the year/make/model/trim data. I was thinking I should use a custom hierarchical taxonomy for these as I will also be storing the user’s car(s) based on these 4 fields. Also, I was thinking of using tags for identifying other item traits such as truck/car, economy/performance, etc.

Due to the size and complexity of this project, I’m looking for experienced feedback on the best approach prior to jumping in. Thank you in advance for any help…

I recently built a site with a large inventory of trucks, which had some similar issues. Some of my major takeaways:

  • Taxonomies work great for any term that’s a string, but you can only (easily) use them with WP’s internal features for Taxonomies. If you want something outside of that (i.e. search for all years between 2013 and 2019) it gets more complicated.
  • Running WP_Query w/ single meta field search param is comparably fast, but more complicated meta queries (i.e. OR queries) get very, very slow.
  • …but meta queries allow you to do cool things like query date or number ranges, etc.
  • That said, if I had it to do over again, I would probably forgo WP_Query and WP’s DB structure entirely: it gets very slow as it scales up. If I was still storing individual items as Post Types, I’d build my own DB table as a big lookup: it would have all the terms, metadata, etc that I want to search on, and then the IDs of the relevant posts. Then I could just write my own optimized SQL to search that table and bypass WP’s slow stuff. You could also write your own SQL to interact directly with WP’s tables, which would also be faster (but also probably more complex, give the way they organize data).

Thanks for the reply. Speed is my single biggest concern as things grow so I avoid a complicated refactor down the road. Interesting you mentioned going outside WP structure as this was something I was also considering when looking longer term, knowing I could maintain efficiency much better so I think I’ll revisit this thought again. I would love to make things easy on myself but also know how WP is as things bloat, especially as traffic become substantial. Thanks again for your thoughts!

Not as complex as your database may become but I recently built an import and search engine for rental objects of various types and built custom DB tables for it. For that project I used Eloquent to create models and it was, simply put, awesome the way it simplified CRUD. A cpl of times I was thinking ”nah, eloquent probably cant handle building this query” and every time it could :slight_smile:

The package I used was https://github.com/tareq1988/wp-eloquent but there seems to be a cpl of ways to do Eloquent in WP.

So in case you havent already, its def. worth checking out.

1 Like

Hm, write an API, completely separate from PHP, WordPress and then let WordPress consume it?

This topic was automatically closed after 42 days. New replies are no longer allowed.