Why can't I access to collections filters through a metaobject field referencing a collection

Why can't I access to collections filters through a metaobject field referencing a collection

Daouda_of_Mist
Shopify Partner
5 0 0

Hello,

 

I want to build a theme using liquid templating but I'm having a problem with metaobjects :

 

I created a metaobject which have a "products" field of type "Reference : Collection".

 

So I tried to create a template page for this metaobject which will display the product list (just like the default Collection page template) but I cant access to the collection filters using metaobject.products.value.filters as I would use collection.filters in the default main-collection-product-grid.liquid template. I just get an empty array instead, and so I can't render the facets.liquid template to setup filters on this page.

 

Any idea on how I could get the filters ? I managed to access to every other data from the collection through this metaobject (products, title, image) but I just cannot acces to theses filters.

 

Daouda

 

Replies 5 (5)

EBOOST
Shopify Partner
1189 310 349

Hi @Daouda_of_Mist ,

You try to check list below:

1. Filter in product index option has been turned on for that metafield yet.

EBOOST_0-1722896922354.png

 

2. Install https://apps.shopify.com/search-and-discovery app

3. Go to Apps -> Search and discovery -> Add filter

EBOOST_1-1722897499125.png

EBOOST_2-1722897671880.png

4. Check data whether has any products that has been added data for this field? It will don't show if that field don't exist on any products of that collection.

 

EBOOST_3-1722897870063.png

 

 

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: eboost10@gmail.com
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips
Daouda_of_Mist
Shopify Partner
5 0 0

Hi,

Thanks for your answer but I think it does not respond to my demand :

- I created a "test_collection" collection

- I created a "Band" metaobject which contains a metafield named "products" of the type Collection

- I cretaed an entry for the "Band" metaobject named "test_metaobject", with the "test_collection" inside the produdct metafield for this entry

 

All the product metafields and indexes are corectly setup, and the filters works on the basic templates ( "/collections/test_collection").

 

The problem is : when I try to create a Liquid template for the "Band" metaobject ("/pages/band/test_metaobject") , I can get the collection of the "products" field through metaobject.products.value, but I cannot get the filters using metaobject.products.value.filters. So when I try to render the facets.liquid template inside the metaobject page template, it renders nothing.

EBOOST
Shopify Partner
1189 310 349

Hi,

Hi @Daouda_of_Mist ,

It's impossible. Because Applied filters are reflected through URL parameters. When you can't use anywhere outside collection template/search template.

You can refer document here https://shopify.dev/docs/storefronts/themes/navigation-search/filtering/storefront-filtering/support...

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: eboost10@gmail.com
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips
Daouda_of_Mist
Shopify Partner
5 0 0

Thanks for your anwser

So you are telling that we cannot manage theses URL parameters on metaobjects template, but only on search or collection page templates.

It's a real shame because it represents a huge limit when it comes to personalizing a Shopify based website site using complex data structures.

It also means that this kind of product listing template is available only for "/collections/xxx" pages which limits also the URL patterns, and this is really bad to maintain the SEO like our old website.

 

Do you know if there is a proper way to redirect the metaobject template to "upgraded" collection templates which could contain all the infos from my "Band" metaobject ? (I also will be necessary to "invert the references" -> putting the Band metaobject inside a metafield of the collection)

EBOOST
Shopify Partner
1189 310 349

Hi @Daouda_of_Mist ,

You try to use Ajax to do it.

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: eboost10@gmail.com
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips