Display all products filtered by a metafield value on the metafield page

Currently I’m trying to migrate my shop from WooCommerce to Shopify.

I’m selling collectible items that have some custom metafields. One examples:

hsmc_meta.scale that has three attributes: title, description and seo_description.

Title might be: ‘1:6’ or ‘1:1’ and the corresponding description: ‘sixth-scale’ or ‘lifesize’.

Now I have setup a page/template for the scale and I want to display all products that have the scale set up. So it should be URL.com - MediaOptions and there I want to list all the lifesize items. I need it for obvious SEO reasons.

It seems daunting that I’m trying for over 2 weeks to achieve something in Shopify that is enabled in WooCommerce by default.

This is the code I tried so far, with help of ChatGPT, but without any success, Shopify simply does not find the products:

{% assign scale_value = request.path | split: '/' | last %}

{% assign matching_products = collections.all.products | where: "metafields.hsmc_meta.scale.description", scale_value %}

{% if matching_products.size > 0 %}
  
    {% for product in matching_products %}
      
      

        
          
          ## {{ product.title }}
          

{{ product.price | money }}

        
      

      
    {% endfor %}
  

{% else %}
  

No products found with the scale "{{ scale_value }}".

{% endif %}

Alternatively I tried to use collections, but I can’t make automated collections based on metafields. The only “quick” solution would be to put every single attribute of the item into tags. But it seems… quite profane.

Let’s say I have further follwing attributes:

Manufacturer, Franchise, Scale, Current Warehouse, Edition/Version

Is really the only solution to mantain every value of the attributes above via tags and then list everything using collections?

Hi mate,

To achieve the URL format you’re aiming for, you’ll need to use metaobjects—possibly two of them. This approach should give you the results you’re looking for. See sample below

PaulMartin_3-1724917143251.png

Once you’ve set up the metaobjects, make sure they reference each other appropriately. In your liquid code within the second metaobject template, ensure that you reference the products you want to display.

If this setup and coding seem a bit overwhelming, I’d be happy to handle it for you for a flat fee of $25. Just let me know if you have any questions or if you’d like further assistance. Good luck, and I hope this helps!