/// <summary> /// Read shopify theme settings from 'config' folder /// </summary> /// <param name="defaultValue"></param> /// <returns></returns> public IDictionary GetSettings(string defaultValue = null) { return _cacheManager.Get(GetCacheKey("GetSettings", defaultValue), "LiquidThemeRegion", () => { DefaultableDictionary retVal = new DefaultableDictionary(defaultValue); //Read first settings from global theme var resultSettings = InnerGetSettings(_globalThemeBlobProvider, ""); //Then load from current theme var currentThemeSettings = InnerGetSettings(_themeBlobProvider, CurrentThemePath); if (currentThemeSettings != null) { if (resultSettings == null) // if there is no default settings, use just current theme { resultSettings = currentThemeSettings; } else { resultSettings.Merge(currentThemeSettings, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Merge }); } } if (resultSettings != null) { var dict = resultSettings.ToObject<Dictionary<string, object>>().ToDictionary(x => x.Key, x => x.Value); retVal = new DefaultableDictionary(dict, defaultValue); } return retVal; }); }
/// <summary> /// Read shopify theme settings from 'config' folder /// </summary> /// <param name="defaultValue"></param> /// <returns></returns> public DefaultableDictionary GetSettings(string defaultValue = null) { return _cacheManager.Get(GetCacheKey("GetSettings", defaultValue), "LiquidThemeRegion", () => { DefaultableDictionary retVal = new DefaultableDictionary(defaultValue); var resultSettings = InnerGetSettings(GlobalThemeLocalPath); if (GlobalThemeLocalPath != CurrentThemeLocalPath) { var currentThemeSettings = InnerGetSettings(CurrentThemeLocalPath); if (currentThemeSettings != null) { resultSettings.Merge(currentThemeSettings, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Merge }); } } if (resultSettings != null) { var dict = resultSettings.ToObject<Dictionary<string, object>>().ToDictionary(x => x.Key, x => x.Value); retVal = new DefaultableDictionary(dict, defaultValue); } return retVal; }); }