Skip to content

Commit 2d798fc

Browse files
committed
Resolves #2146 multistore blog post issue
1 parent 094e739 commit 2d798fc

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ Merging the contents of different languages must be done manually (migration is
9292
* Google Analytics: Fixed script error in conjunction with CookieManager
9393
* #2085 RTL: searchbar button wasn't aligned correctly
9494
* #2068 RTL: Fixed Page Builder slider positioning, dropdown and other alignments
95-
* #2019 OffCancas compare: hide horizontal scrollbar
95+
* #2019 OffCancas compare: hide horizontal scrollbar
96+
* #2146 LimitedToStores property was not set in a rare case.
9697

9798
## Smartstore 4.0.1
9899
### New Features

src/Libraries/SmartStore.Services/Stores/StoreMappingService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,15 @@ public virtual void SaveStoreMappings<T>(T entity, int[] selectedStoreIds) where
8787
{
8888
var existingStoreMappings = GetStoreMappings(entity);
8989
var allStores = _storeService.GetAllStores();
90+
var selectedIds = selectedStoreIds ?? Array.Empty<int>();
91+
92+
entity.LimitedToStores = selectedIds.Length == 1 && selectedIds[0] == 0
93+
? false
94+
: selectedIds.Any();
9095

9196
foreach (var store in allStores)
9297
{
93-
if (selectedStoreIds != null && selectedStoreIds.Contains(store.Id))
98+
if (selectedIds.Contains(store.Id))
9499
{
95100
if (!existingStoreMappings.Any(x => x.StoreId == store.Id))
96101
InsertStoreMapping(entity, store.Id);
@@ -102,6 +107,8 @@ public virtual void SaveStoreMappings<T>(T entity, int[] selectedStoreIds) where
102107
DeleteStoreMapping(storeMappingToDelete);
103108
}
104109
}
110+
111+
_storeMappingRepository.Context.SaveChanges();
105112
}
106113

107114
public virtual void InsertStoreMapping(StoreMapping storeMapping)

src/Presentation/SmartStore.Web.Framework/Controllers/ManageController.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ protected virtual void SaveStoreMappings<T>(T entity, int[] selectedStoreIds) wh
5858
{
5959
Guard.NotNull(entity, nameof(entity));
6060

61-
entity.LimitedToStores = (selectedStoreIds?.Length ?? 0) == 1 && selectedStoreIds[0] == 0
62-
? false
63-
: selectedStoreIds?.Any() ?? false;
64-
6561
Services.Resolve<IStoreMappingService>().SaveStoreMappings(entity, selectedStoreIds);
6662
}
6763

0 commit comments

Comments
 (0)