A space to discuss online store customization, theme development, and Liquid templating.
Hi there,
We've been looking at the developer preview and are excited about deploying this on upcoming projects.
One of the use cases we're considering is syncing content across multiple plus stores. If a user creates a blog post on one site, we want to copy that to another site using the API.
On current non-sectioned pages that would be fairly straightforward, as most of the content would reside in the body_html property.
How could this be approached on sectioned blog posts (assuming the two stores share a common theme)?
Any pointers appreciated. Thanks.
Hi there @Chris_Marshall1
Thanks for getting in touch and we're glad to hear you're excited to start using the new theme architecture on your projects. The use-case you've described should be possible, but it will be slightly more complex than how you would presently transfer content like a blog post across different Shopify stores.
Since all of the store data (like blog post content) is accessible through the Admin API it will be possible to copy content from one store to another. However, you'll be copying sections_data (instead of body_html) which contains references to resources such as products, collections, etc. by ID, and IDs (unlike handles) cannot be the same across shops. This means that during the process of copying sections_data you'll need to replace the product/etc. IDs of shop A with the IDs of the equivalent product/etc. in shop B.
Hope this helps Chris- there's some more info on this on our help docs here.
Cheers,
Liam Griffin
Shopify | Developer Community Manager
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks @Liam - that makes sense, but would require that we maintain some form of mapping of IDs between the sites. This is of course possible, but there's an overhead. We know the handles are going to be the same between the two sites, so if we had the handle we could smooth this.
I have an alternative solution which I've tested and appears to work, but would greatly appreciate your thoughts.
Taking the 'Featured product' type:
This seems to work well, and gives us the handle via the API:
{ "after": "158486273386377e0b", "section": { "id": "158486465870edce43", "content": { "static": [ { "id": "15848646580031af74", "type": "custom", "settings": {} } ], "blocks": [] }, "settings": { "product_link": { "type": "url", "value": "shopify://products/jumper" }, "image_size": { "type": "select", "value": "medium" },
This would work for collections, pages and articles too.
Anything we'd need to consider here?
Thanks
Chris
Hi again @Chris_Marshall1
The process you've described would work but we wouldn't recommend this approach because it leads to bad UX (adopting a URL picker instead of a product picker), and using the custom content type means the content would not be portable across themes. The lack of portability across themes may not a concern in the short-run, but when you make major redesigns theme portability could be helpful.
Additionally using the all_products global carries the risk of running into the "20 per page" limit described here which makes it likely that pages with a lot of sections will error out.
Hope this helps Chris!
Liam
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks Liam, that's really useful feedback.
We could live with the less-than-perfect UX. The all_products limit is a definite blocker tho' - pah!
The options to sync content across sites therefore are:
OK thanks - need to do some thinking!
Hi @Liam
Another question on this. If we were having to sync images - obviously there's no files API. If we were to replace the 'shopify://shop_images/' in the below with the URL/path of the originating site, would this work? Would it reference the original URL or would it import it anew into the CDN?
{ "id": "1581529975ac14d4cc", "type": "image", "value": "shopify://shop_images/confident-young-woman.jpg", "settings": { "width": { "type": "select", "value": "50%" }, "alignment": { "type": "select", "value": "middle" } } }