How to Get Store Configuration Using GraphQL in Magento 2

Do you want to know how to get store configurations using GraphQL Query in Magento 2?

In this Magento 2 GraphQL Tutorial, We will show how to get store configurations using GraphQL Query in Magento 2. We will use the storeConfig query to get information about a store’s configuration.

Let’s start!

Get Store’s Configuration Query:

The storeConfig query can return base and extended store configuration setting. The following call returns all base details of a store’s configuration.

{
  storeConfig {
    store_code
    store_name
    is_default_store
    store_group_code
    is_default_store_group
    locale
    base_currency_code
    default_display_currency_code
    timezone
    weight_unit
    base_url
    base_link_url
    base_static_url
    base_media_url
    secure_base_url
    secure_base_link_url
    secure_base_static_url
    secure_base_media_url
  }
}

Output:

{
  "data": {
    "storeConfig": {
      "store_code": "default",
      "store_name": "Default Store View",
      "is_default_store": true,
      "store_group_code": "main_website_store",
      "is_default_store_group": true,
      "locale": "en_US",
      "base_currency_code": "USD",
      "default_display_currency_code": "USD",
      "timezone": "America/Chicago",
      "weight_unit": "lbs",
      "base_url": "https://www.yourstore.com/",
      "base_link_url": "https://www.yourstore.com/",
      "base_static_url": "https://www.yourstore.com/pub/static/version1606976517/",
      "base_media_url": "https://www.yourstore.com/pub/media/",
      "secure_base_url": "https://www.yourstore.com/",
      "secure_base_link_url": "https://www.yourstore.com/",
      "secure_base_static_url": "https://www.yourstore.com/pub/static/version1606976517/",
      "secure_base_media_url": "https://www.yourstore.com/pub/media/"
    }
  }
}

In the above GraphQL query, you can see we have used basic useful fields which will help you to get basic information about your store.


Get Store’s Default Title, Keywords and Welcome Text Query:

The following query will help you to get information about the store’s default title, keywords, and welcome text.

{
  storeConfig {
    default_title
    default_keywords
    welcome
  }
}

Output:

{
  "data": {
    "storeConfig": {
      "default_title": "Magento Enterprise Edition",
      "default_keywords": "Magento, Varien, E-commerce",
      "welcome": "Default welcome msg!"
    }
  }
}

Get Store’s CMS Configuration Query:

The following query will help you to get information about the store’s cms pages.

{
  storeConfig {
    front
    cms_home_page
    no_route
    cms_no_route
    cms_no_cookies
    show_cms_breadcrumbs
  }
}

Output:

{
  "data": {
    "storeConfig": {
      "front": "cms",
      "cms_home_page": "home",
      "no_route": "cms/noroute/index",
      "cms_no_route": "no-route",
      "cms_no_cookies": "enable-cookies",
      "show_cms_breadcrumbs": 1
    }
  }
}

Get Store’s Catalog Configuration Query:

The following query will help you to get information about the store’s catalog configuration.

{
  storeConfig {
    product_url_suffix
    category_url_suffix
    title_separator
    list_mode
    grid_per_page_values
    list_per_page_values
    grid_per_page
    list_per_page
    catalog_default_sort_by
  }
}

Output:

{
  "data": {
    "storeConfig": {
      "product_url_suffix": ".html",
      "category_url_suffix": ".html",
      "title_separator": "-",
      "list_mode": "grid-list",
      "grid_per_page_values": "9,15,30",
      "list_per_page_values": "5,10,15,20,25",
      "grid_per_page": 9,
      "list_per_page": 10,
      "catalog_default_sort_by": "position"
    }
  }
}

Get Store’s Customer Configuration Query:

The following query will help you to get information about the store’s customer configuration.

{
    storeConfig {
        autocomplete_on_storefront
        minimum_password_length
        required_character_classes_number
    }
}

Output:

{
  "data": {
    "storeConfig": {
      "autocomplete_on_storefront": true,
      "minimum_password_length": "6",
      "required_character_classes_number": "2"
    }
  }
}

Get Store’s Fixed Product Tax Configuration Query:

The following query will help you to get information about the store’s fixed product tax configuration.

{
  storeConfig {
    category_fixed_product_tax_display_setting
    product_fixed_product_tax_display_setting
    sales_fixed_product_tax_display_setting
  }
}

Output:

{
  "data": {
    "storeConfig": {
      "category_fixed_product_tax_display_setting": "EXCLUDE_FPT_WITHOUT_DETAILS",
      "product_fixed_product_tax_display_setting": "EXCLUDE_FPT_AND_INCLUDE_WITH_DETAILS",
      "sales_fixed_product_tax_display_setting": "INCLUDE_FPT_WITHOUT_DETAILS"
    }
  }
}

You can use ChromeiQL tool to test and run GraphQL Query in Magento 2.

How to Get Store Configuration Using GraphQL in Magento 2 Click To Tweet

If you liked this tutorial, then please subscribe to our Newsletter for Magento tutorials. You can also find us on Twitter and Facebook. If you have any problem or would like to add to the discussion, leave a comment below!

You May Also Like

Editorial Staff

About the Author: Editorial Staff

Editorial Staff at the MageBeginners is a team of Magento experts writing about Magento Tutorials, Themes, Extensions, Guides, Tricks and much more...

Leave a Reply

Your email address will not be published. Required fields are marked *