skip to Main Content

I am developing shopify public app. I just want to know that can I get store home page content for upadte and add new content there.

I am getting all pages details and it contents by using shopify admin API for get page,create page,update page and delete page

like here we use following path for update particular page with page_id

PUT /admin/api/2019-04/pages/#{page_id}.json
{
  "page": {
    "id": 131092082,
    "body_html": "<p>Returns accepted if we receive the items 14 days after purchase.</p>"
  }
}

I had details of all static pages but i don’t know how to update home page details like this

Can any one please help me that how I can get home page content and update that content using API or refer me any admin API to get this. Thank you

2

Answers


  1. Chosen as BEST ANSWER

    Finally got the solution to update index.liquid page of shopify store as follow

    First you have to get themes by following

    GET  https://shop_domain/admin/api/2019-04/themes.json
    

    This API give you thmes.json which contains all themes details used in this store.

    Now you have to get theme_id from theme.json for update particular page by theme_id. Update asset API for update content of index page

    URL for update assets by theme_id

    PUT https://shop_domain/admin/api/2019-04/themes/#{theme_id}/assets.json
    

    require body for update API

    {
      "asset": {
        "key": "templates/index.liquid",
        "value": "add your content"
      }
    }
    

    And this will update index page content with your content . It work successfully for me Thank you


  2. The smart way to do this is as follows. In the theme itself, you can tell when you are on the index page since Shopify renders index.liquid. In there, you can make a callback to your App using the App Proxy. The App then provides custom data as JSON or perhaps even Liquid. So the index page can now render with your App being part of the cycle.

    That is probably the best pattern for you to work with for your specifics.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search