Magento 2 How to get Store Configuration in GraphQL

We all know that Magento provides some facilities in the backend, so we will explaine to you how to get Store Configuration Data using GraphQL.

We will use the storeConfig query to define information about a store's configuration.

Syntax

Copy
storeConfig: StoreConfig

Here, explained all configuration data using storeConfig query. Now first of all, we will show you how to get details of the store's configuration.

Query a store’s configuration

The following query returns all details of store's configuration.

Request

Copy
{
  storeConfig {
    id
    code
    website_id
    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
    store_name
  }
}

Response

Copy
{
  "data": {
    "storeConfig": {
      "id": 1,
      "code": "default",
      "website_id": 1,
      "locale": "en_US",
      "base_currency_code": "USD",
      "default_display_currency_code": "USD",
      "timezone": "UTC",
      "weight_unit": "lbs",
      "base_url": "https://domain.com/",
      "base_link_url": "https://domain.com/",
      "base_static_url": "https://domain.com/pub/static/",
      "base_media_url": "https://domain.com/pub/media/",
      "secure_base_url": "https://domain.com/",
      "secure_base_link_url": "https://domain.com/",
      "secure_base_static_url": "https://domain.com/pub/static/",
      "secure_base_media_url": "https://domain.com/pub/media/",
      "store_name": null
    }
  }
}

Query a store’s theme

Now, we will show you how to get details of theme configuration using this query.

The following query returns about the store's default title, keywords and welcome text.

Request

Copy
{
  storeConfig {
    default_title
    default_keywords
    welcome
  }
}

Response

Copy
{
  "data": {
    "storeConfig": {
      "default_title": "Magento Commerce",
      "default_keywords": null,
      "welcome": "Default welcome msg!"
    }
  }
}

Query a store’s CMS configuration

Now, we will show you how to get details of CMS configuration using this query.

The following query returns information about the store's content pages.

Request

Copy
{
  storeConfig {
    front
    cms_home_page
    no_route
    cms_no_route
    cms_no_cookies
    show_cms_breadcrumbs
  }
}

Response

Copy
{
  "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
    }
  }
}

Query a store’s Catalog configuration

Now, we will show you how to get details of Catalog configuration using this query.

The following query returns information about the store's catalog configuration.

Request

Copy
{
  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
  }
}

Response

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

Query a store’s fixed product tax configuration

Now, we will show you how to get details of the store’s fixed product tax configuration using this query.

The following query returns enumeration values that indicate the store’s fixed product tax configuration.

Request

Copy
{
  storeConfig {
    category_fixed_product_tax_display_setting
    product_fixed_product_tax_display_setting
    sales_fixed_product_tax_display_setting
  }
}

Response

Copy
{
  "data": {
    "storeConfig": {
      "category_fixed_product_tax_display_setting": "INCLUDE_FPT_WITH_DETAILS",
      "product_fixed_product_tax_display_setting": "INCLUDE_FPT_WITH_DETAILS",
      "sales_fixed_product_tax_display_setting": "INCLUDE_FPT_WITH_DETAILS"
    }
  }
}

That's it!!

If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.

I hope this article helps you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

P.S. Do share this article with your team.




Search
Recent Posts
    Tags
    Newsletter
    SocialFollow on Twitter
    Visit now!