Recommended products only show products from the same vendor Dawn theme

Hi There!

Using the Dawn theme, the recommended products that get shown are irrelevant as our store is for motor vehicle accessories, they often show products for different vehicles to what is on the page.

I have set up the vehicles as vendors as all the products are produced by us.

My question is how can I get product recommendations to only show products from the same vendor as the product on the page? This is the code for the recommendations block as it stands


Thanks in advance
Trent

Hi @trentluke

Caveat - Keep in mind you can end up with NO recommendations relying on that match. Recommendations are auto-generated based on an algorithm so there’s always a chance there is zero overlap between the product being viewed and any of its recommendations sharing the same “vendor”.

At minimum if that occurse try skewing the auto recommendations algorithm by making sure products that should be recommended with each other have similar product description content, and are in the same collections as much as possible. Or more extreme make a bunch of orders to build up the purchase relations history.

Always backup|export a theme or files before making changes to code

You may be able to use the where filter on the recommendations.product array to get just products of that vendor|vehicle

{% assign recommendation_vendor == "vendorNameVariableOrVendorNameString" %}
{% assign recommendation_parts == recommendations.products | where: "vendor",recommendation_vendor %}
{% for recommendation in recommendation_parts %}
....

https://shopify.dev/api/liquid/filters/array-filters#where

https://shopify.dev/api/liquid/objects/recommendations

Otherwise try skipping any products not the same vendor

{% for recommendation in recommendations.products %}
{% if recommendation.vendor != product.vendor %} {% continue %} {% endif %}

https://shopify.dev/api/liquid/tags/iteration-tags#continue

Tag based recommendations

Alternatively you might get finer initial control using the tag based recommendations method to at least constrain what ends up in peoples carts and thus the algorithm|data that the auto-recommendation uses for it’s recommendations.

Also keep in mind that showing alternative products isn’t necessarily the best method for increasing conversions/AOV/etc., showing complementary products may work better. It depends on what you’re selling and to whom, run some A/B tests to be sure.