1

I am considered the best way to set this up in Craft and how to handle this with front-end Urls, templates and routes?

So I products with variants for Wheel Spacers, (Wheel Spacers are a product type), these wheel spacers will be related to specific vehicles (vehicles is a separate channel). As these spacers will be related to several vehicles, it doesn't make sense to duplicate them as multiple products.

However, the part I am stuck with is how to list these products in multiple instances on the front-end so that it uses the same product but various information is pulled in from the vehicle. As an example.

Say the product 4x100 56.1 Wheel Spacers (4100561) relates to the following vehicles:

  • Audi Q7 (2009-15)
  • Mini Cooper S (2002-2006)
  • Mini Cooper S (2006-2012)
  • Mini Cooper (2008-2012)
  • Mini Cooper (2012-)
  • BMW Z1 (2012-)

I would like to show the product 4x100 56.1 Wheel Spacers (4100561) as separate pages for each of those models. With each one showing dynamic information for the SEO meta, and description, this would be pulled in dynamically e.g

  • Audi Q7 (2009-15) 4x100 56.1 Wheel Spacer
  • Mini Cooper S (2002-2006) 4x100 56.1 Wheel Spacer
  • Mini Cooper S (2006-2012) 4x100 56.1 Wheel Spacer
  • Mini Cooper (2008-2012) 4x100 56.1 Wheel Spacer
  • Mini Cooper (2012-) 4x100 56.1 Wheel Spacer
  • BMW Z1 (2012-) 4x100 56.1 Wheel Spacer

At the same time user will be able to browser by product types (Wheel Spacers, Adapters, Fixings etc) but also by Vehicle Manufacture (Audi) and Model (Q7 (2009-15)) etc

If anyone can give me thoughts on the best way to structure this in Craft CMS and how to best structure the templates, the URLs and routes?

Thanks,

2

Go to admin panel settings->routes And do something like:

First * is your product-slug, Second * is your variant unique value, could be SKU or some other custom field you have.

enter image description here

Then in your your-product-detail.twig

   {% set productSlug = craft.app.request.segments()[1] %} 
   {% set variantUniqueValue = craft.app.request.segments()[2] %}

Then based on these two values, do craft variant query to get variant information and display it.

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.