Retrieving liquid templates using the API.

Evan_Pavlica
Shopify Partner
8 0 0

Hello,

We're trying to *append* a bock of HTML to liquid templates using the API. All our attempts failed.

  • - When we retrieve an asset using `ShopifyAPI::Asset.find :all`, the items all have `nil` as their `value` field.
  • - Then, if we assign something to the value and save the asset, it completelly overwrites the original asset.
  • - Then, if we re-fetch the same asset, its value field is nil again.

Very frustrating indeed. How do you get the actual content of a liquid asset please?

 

Also, we don't understand how to actually find a template using its key. Eg how would one just retrieve one asset using its name:

ShopifyApi::Asset.find key: 'templates/index.liquid'

 

Thank you!

0 Likes
TomTranzistor
Shopify Partner
31 2 5

Hey there, 

 

You have to specify which theme

 

ShopifyAPI::Asset.find('assets/app.js', params: { theme_id: params[:theme_id] })

Thene you modify then you save it !)

Let us help you - Tranzistor.tech
0 Likes