Skip to content

Commit 4963935

Browse files
committed
Store logo moved from settings to store entity
1 parent 9f15ec4 commit 4963935

15 files changed

Lines changed: 96 additions & 60 deletions

File tree

migrations/1.0.1-next/migrate-multistore.sql

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ set @resources='
3333
<Value>Please provide a name.</Value>
3434
<T>Bitte einen Namen angeben.</T>
3535
</LocaleResource>
36+
<LocaleResource Name="Admin.Configuration.Stores.Fields.StoreLogo">
37+
<Value>Store logo</Value>
38+
<T>Shop Logo</T>
39+
</LocaleResource>
40+
<LocaleResource Name="Admin.Configuration.Stores.Fields.StoreLogo.Hint">
41+
<Value>Upload your store logo</Value>
42+
<T>Ein Shop Logo hochladen</T>
43+
</LocaleResource>
3644
<LocaleResource Name="Admin.Configuration.Stores.Fields.DisplayOrder">
3745
<Value>Display order</Value>
3846
<T>Reihenfolge</T>
@@ -214,7 +222,7 @@ set @resources='
214222
<T>HTTP_HOST wird in einer Multi-Shop Umgebung benötigt, um den aktuellen Shop zu ermitteln.</T>
215223
</LocaleResource>
216224
217-
<LocaleResource Name="Admin.Configuration.Settings.GeneralCommon.StoreName">
225+
<LocaleResource Name="Admin.Configuration.Settings.GeneralCommon.StoreName">
218226
<Value></Value>
219227
<T></T>
220228
</LocaleResource>
@@ -230,6 +238,14 @@ set @resources='
230238
<Value></Value>
231239
<T></T>
232240
</LocaleResource>
241+
<LocaleResource Name="Admin.Configuration.Settings.GeneralCommon.StoreLogo">
242+
<Value></Value>
243+
<T></T>
244+
</LocaleResource>
245+
<LocaleResource Name="Admin.Configuration.Settings.GeneralCommon.StoreLogo.Hint">
246+
<Value></Value>
247+
<T></T>
248+
</LocaleResource>
233249
<LocaleResource Name="Admin.Configuration.Stores.Fields.Url">
234250
<Value>Store URL</Value>
235251
<T>Shop URL</T>
@@ -735,6 +751,7 @@ BEGIN
735751
[SslEnabled] bit NOT NULL,
736752
[SecureUrl] nvarchar(400) NULL,
737753
[Hosts] nvarchar(1000) NULL,
754+
[LogoPictureId] int NOT NULL,
738755
[DisplayOrder] int NOT NULL,
739756
PRIMARY KEY CLUSTERED
740757
(
@@ -749,17 +766,27 @@ BEGIN
749766
SET @DEFAULT_STORE_NAME = N'Your store name'
750767

751768
DECLARE @DEFAULT_STORE_URL nvarchar(400)
752-
SELECT @DEFAULT_STORE_URL= [Value] FROM [Setting] WHERE [name] = N'storeinformationsettings.storeurl'
769+
SELECT @DEFAULT_STORE_URL = [Value] FROM [Setting] WHERE [name] = N'storeinformationsettings.storeurl'
753770

754771
if (@DEFAULT_STORE_URL is null)
755772
SET @DEFAULT_STORE_URL = N'http://www.yourstore.com/'
773+
774+
DECLARE @DEFAULT_STORE_LOGOSETTING nvarchar(400)
775+
SELECT @DEFAULT_STORE_LOGOSETTING = [Value] FROM [Setting] WHERE [name] = N'storeinformationsettings.logopictureid'
776+
777+
if (@DEFAULT_STORE_LOGOSETTING is null)
778+
SET @DEFAULT_STORE_LOGOSETTING = 0
779+
780+
DECLARE @DEFAULT_STORE_LOGOPICTUREID int
781+
SET @DEFAULT_STORE_LOGOPICTUREID = CAST(@DEFAULT_STORE_LOGOSETTING AS INT)
756782

757783
--create the first store
758-
INSERT INTO [Store] ([Name], [Url], [SslEnabled], [Hosts], [DisplayOrder])
759-
VALUES (@DEFAULT_STORE_NAME, @DEFAULT_STORE_URL, 0, N'yourstore.com,www.yourstore.com', 1)
784+
INSERT INTO [Store] ([Name], [Url], [SslEnabled], [Hosts], [LogoPictureId], [DisplayOrder])
785+
VALUES (@DEFAULT_STORE_NAME, @DEFAULT_STORE_URL, 0, N'yourstore.com,www.yourstore.com', CAST(@DEFAULT_STORE_LOGOPICTUREID AS INT), 1)
760786

761787
DELETE FROM [Setting] WHERE [name] = N'storeinformationsettings.storename'
762-
DELETE FROM [Setting] WHERE [name] = N'storeinformationsettings.storeurl'
788+
DELETE FROM [Setting] WHERE [name] = N'storeinformationsettings.storeurl'
789+
DELETE FROM [Setting] WHERE [name] = N'storeinformationsettings.logopictureid'
763790
END
764791
GO
765792

src/Libraries/SmartStore.Core/Domain/StoreInformationSettings.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
namespace SmartStore.Core.Domain
44
{
55
public class StoreInformationSettings : ISettings
6-
{
7-
8-
/// <summary>
9-
/// Gets or sets a store name
10-
/// </summary>
11-
public int LogoPictureId { get; set; }
12-
6+
{
137
/// <summary>
148
/// Gets or sets a value indicating whether store is closed
159
/// </summary>
@@ -26,6 +20,5 @@ public class StoreInformationSettings : ISettings
2620
/// Gets or sets a value indicating whether mini profiler should be displayed in public store (used for debugging)
2721
/// </summary>
2822
public bool DisplayMiniProfilerInPublicStore { get; set; }
29-
3023
}
3124
}

src/Libraries/SmartStore.Core/Domain/Stores/Store.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public partial class Store : BaseEntity
3131
/// </summary>
3232
public string Hosts { get; set; }
3333

34+
/// <summary>
35+
/// Gets or sets the logo picture id
36+
/// </summary>
37+
public int LogoPictureId { get; set; }
38+
3439
/// <summary>
3540
/// Gets or sets the display order
3641
/// </summary>

src/Libraries/SmartStore.Services/Installation/InstallationService.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,14 @@ private void RecursivelySortChildrenResource(LocaleStringResourceParent resource
314314

315315
private void InstallStores()
316316
{
317-
var stores = new List<Store>()
318-
{
319-
new Store()
320-
{
321-
Name = "Your store name",
322-
Url = "http://www.yourStore.com/",
323-
SslEnabled = false,
324-
Hosts = "yourstore.com,www.yourstore.com",
325-
DisplayOrder = 1,
326-
},
327-
};
328-
329-
stores.ForEach(x => _storeRepository.Insert(x));
317+
try
318+
{
319+
_storeRepository.InsertRange(_installData.DefaultStores());
320+
}
321+
catch (Exception ex)
322+
{
323+
throw new InstallationException("InstallStores", ex);
324+
}
330325
}
331326

332327
private void InstallMeasureDimensions()

src/Libraries/SmartStore.Services/Installation/InvariantInstallationData.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using SmartStore.Core.Domain.Security;
3030
using SmartStore.Core.Domain.Seo;
3131
using SmartStore.Core.Domain.Shipping;
32+
using SmartStore.Core.Domain.Stores;
3233
using SmartStore.Core.Domain.Tasks;
3334
using SmartStore.Core.Domain.Tax;
3435
using SmartStore.Core.Domain.Themes;
@@ -4212,10 +4213,28 @@ public IList<Topic> Topics()
42124213
return entities;
42134214
}
42144215

4216+
public IList<Store> DefaultStores()
4217+
{
4218+
var imgCompanyLogo = _pictureService.InsertPicture(File.ReadAllBytes(_sampleImagesPath + "company_logo.png"), "image/png", "", true, false);
4219+
4220+
var stores = new List<Store>()
4221+
{
4222+
new Store()
4223+
{
4224+
Name = "Your store name",
4225+
Url = "http://www.yourStore.com/",
4226+
SslEnabled = false,
4227+
Hosts = "yourstore.com,www.yourstore.com",
4228+
LogoPictureId = imgCompanyLogo.Id,
4229+
DisplayOrder = 1,
4230+
},
4231+
};
4232+
return stores;
4233+
}
4234+
42154235
public IList<ISettings> Settings()
42164236
{
42174237
var imgContentSliderBg = _pictureService.InsertPicture(File.ReadAllBytes(_sampleImagesPath + "clouds.png"), "image/png", "", true, false);
4218-
var imgCompanyLogo = _pictureService.InsertPicture(File.ReadAllBytes(_sampleImagesPath + "company_logo.png"), "image/png", "", true, false);
42194238

42204239
var entities = new List<ISettings>
42214240
{
@@ -4397,7 +4416,6 @@ public IList<ISettings> Settings()
43974416
},
43984417
new StoreInformationSettings()
43994418
{
4400-
LogoPictureId = imgCompanyLogo.Id,
44014419
StoreClosed = false,
44024420
StoreClosedAllowForAdmins = true,
44034421

src/Libraries/SmartStore.Services/Localization/LocalizationService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ public virtual string GetResource(string resourceKey, int languageId = 0, bool l
311311
where l.ResourceName == resourceKey && l.LanguageId == languageId
312312
select l;
313313
var res = query.FirstOrDefault();
314-
return new Tuple<int, string>(res.Id, res.ResourceValue);
314+
if (res != null) // codehint: sm-edit (null case)
315+
return new Tuple<int, string>(res.Id, res.ResourceValue);
316+
return null;
315317
});
316318
}
317319
catch { }

src/Plugins/Feed.ElmarShopinfo/Services/ElmarShopinfoCoreService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,11 @@ private string CreateXml(Stream stream, Store store, GeneratedFeedFile feedFile,
251251
});
252252
});
253253

254-
var storeInformationSettings = _settingService.LoadSetting<StoreInformationSettings>(store.Id);
255-
var logoUrl = _pictureService.GetPictureUrl(storeInformationSettings.LogoPictureId);
256-
257-
writer.WriteCData("Logo", logoUrl);
254+
if (store.LogoPictureId != 0)
255+
{
256+
var logoUrl = _pictureService.GetPictureUrl(store.LogoPictureId);
257+
writer.WriteCData("Logo", logoUrl);
258+
}
258259

259260
writer.WriteNode("Address", () =>
260261
{

src/Presentation/SmartStore.Web.Framework/HtmlExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public static MvcHtmlString SettingOverrideCheckbox<TModel, TValue>(this HtmlHel
479479
{
480480
var data = helper.ViewData["StoreDependingSettingData"] as StoreDependingSettingData;
481481

482-
if (data.ActiveStoreScopeConfiguration > 0)
482+
if (data != null && data.ActiveStoreScopeConfiguration > 0)
483483
{
484484
var settingKey = ExpressionHelper.GetExpressionText(expression);
485485

src/Presentation/SmartStore.Web/Administration/Controllers/SettingController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,6 @@ public ActionResult GeneralCommon(string selectedTab)
957957

958958
//store information
959959
var storeInformationSettings = _settingService.LoadSetting<StoreInformationSettings>(storeScope);
960-
model.StoreInformationSettings.LogoPictureId = storeInformationSettings.LogoPictureId;
961960
model.StoreInformationSettings.StoreClosed = storeInformationSettings.StoreClosed;
962961
model.StoreInformationSettings.StoreClosedAllowForAdmins = storeInformationSettings.StoreClosedAllowForAdmins;
963962

@@ -1121,7 +1120,6 @@ public ActionResult GeneralCommon(GeneralCommonSettingsModel model, string selec
11211120

11221121
//store information
11231122
var storeInformationSettings = _settingService.LoadSetting<StoreInformationSettings>(storeScope);
1124-
storeInformationSettings.LogoPictureId = model.StoreInformationSettings.LogoPictureId;
11251123
storeInformationSettings.StoreClosed = model.StoreInformationSettings.StoreClosed;
11261124
storeInformationSettings.StoreClosedAllowForAdmins = model.StoreInformationSettings.StoreClosedAllowForAdmins;
11271125

src/Presentation/SmartStore.Web/Administration/Models/Settings/GeneralCommonSettingsModel.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ public StoreInformationSettingsModel()
5151
// codehint: sm-delete
5252
}
5353

54-
//codehint: sm-add
55-
[SmartResourceDisplayName("Admin.Configuration.Settings.GeneralCommon.StoreLogo")]
56-
[UIHint("Picture")]
57-
public int LogoPictureId { get; set; }
58-
5954
// codehint: sm-delete
6055

6156
[SmartResourceDisplayName("Admin.Configuration.Settings.GeneralCommon.StoreClosed")]

0 commit comments

Comments
 (0)