Ecommerce

Building a year/make/model search that doesn’t fall over

Fitment search looks simple until the data gets big. How to structure it so shoppers get the right part and the server stays calm.

Close-up of a car’s speedometer and tachometer

“Find parts for your vehicle” is one of the most useful features an auto or equipment store can have. It’s also easy to build in a way that gets slower with every product you add.

Model the data first

Vehicles and products have a many-to-many relationship: one battery fits hundreds of vehicles, and one vehicle fits several batteries. Storing that in post meta works for a demo and falls over in production. Give fitment its own indexed table.

CREATE TABLE wp_fitment (
  product_id BIGINT UNSIGNED NOT NULL,
  year       SMALLINT NOT NULL,
  make       VARCHAR(64) NOT NULL,
  model      VARCHAR(64) NOT NULL,
  KEY ymm (year, make, model)
);

Cascade the dropdowns

Each choice narrows the next: pick a year, get the makes for that year; pick a make, get the models. A small endpoint returns distinct values for each step. Fitment data changes rarely, so cache those responses aggressively.

Keep the queries cheap

  • Query the fitment table for product IDs, then hand those IDs to WooCommerce.
  • Avoid large meta queries on big catalogs.
  • Paginate results, and only load what’s on screen.

Make it forgiving

  • Remember the shopper’s vehicle as they browse.
  • Show a clear “fits your vehicle” badge on product pages.
  • Offer an equipment search for things that aren’t cars.
  • Write helpful empty states instead of “no results.”

The finder is only as good as the fitment data behind it. Budget real time for importing and cleaning it.

Tim Dalbey