Goal: Show on product pages the blog posts (recipes) that reference those products, using a blog article metafield of type Product List (a metafield is a custom data field; Product List stores product references).
Constraints: 500+ articles require a reverse lookup (product ā articles). Shopify lacks an article/blog reference metafield type, and Shopify Flow canāt trigger on new articles.
Approaches considered:
Liquid (Shopifyās templating language) nested loops over all articles and each articleās product-list metafield to find matches; possible but likely too slow at this scale.
Put related article handles in a product metafield (e.g., list of strings) and render server-side via articles[āblog-handle/article-handleā]; efficient at render time but creates manual upkeep whenever new posts are published.
Build automation/app to sync: watch for new articles and copy relationships into product metafields; could be a private Rails app or a noācode workflow with Make. Hiring a Shopify Expert is also suggested.
Current direction: Moving toward a custom/private app to leverage existing blog metafield data while avoiding manual updates.
Open questions: Whether a GraphQL (API query language) query can fetch articles by a product referenced in a metafield (potentially for Mechanic or a custom app) remains unanswered. A brief Liquid snippet was shared for article-by-handle access.
This does sound like custom app territory as I havenāt come across an existing app that does this. Iām confident one of our Shopify experts would be able to accomplish this at a reasonable price.
Just wanted to share this as an option in case you are unable to find a coding solution in your thread.
If there is anything else I can help you with, please let me know.
So, what you want to do is suggest related blog articles in product pages right?
There is a way to loop over all blog articles in your product page, and then for each blog article loop over the product list metafields to see if there is a match. The main issue with this approach is that it is a nested loop startegy, knowing that you have 500+ articles⦠There is a trick to achieve this using pagination (not tried for awhile but I think this can work) ; but to be frank, this is taking the problem from the wrong end, and is not a great idea for performance.
Since what you need to modify is the product page, could you not add a metafield in your product page instead of blog page? This metafield would be a list of related blog articles for your product.
Shopify is known for doing some things halfway, and I have no idea why there is not a blog or article reference available in metafields. So until this becomes a thing, you could still create a metafields of type āsingle line texteā with ālist of valuesā option. And for each product, you would add the articles āhandleā that you want.
You can access a blog article in product page by its handle like this (here Iām assuming there is only one blog):
Thanks Max. Iāve considered that, but we donāt want the work flow of updating multiple productsā metafields every time we have a new blog post. The management will be unwieldy.
I think weāll need to make a custom app. The data already exists in Shopify so itās a matter of getting it out.
You will still need to figure out how you render the blog post articles in your product pages. If you want the blog articles to be rendered server-side, using product metafields seems like a good approach (as I explained above).
I guess your app could be watching for when new articles are created, and create/migrate metafields data to the product metafield. By the way this can be done in a quick fashion using a āno-codeā tool such as Make (Shopify Flow does not support yet watching for new articles).
Just curious, what kind of related blog posts are you showing on the product pages? Is that a way of driving traffic to the blog posts, or are they specifically relevant to those products? Sounds pretty cool.
We have recipes featuring food products, so want the product pages to link to the specific recipes that use them, without creating extra work to go link/unlink outside of setting the product list metafield on the recipe. Thanks!
Anyone knows the point of the blog post metafield under products? I added a metafield for blog posts, selected blog posts per product, but the theme editor does not show āblog postsā as an option in dynamic sourcing.