@@ -70,18 +70,21 @@ public function migrateSetting(string $scope = ScopeConfigInterface::SCOPE_TYPE_
70
70
return ;
71
71
}
72
72
73
- // Replicate the global settings by turning on virtual replicas for all attributes
74
- $ virtualizedSorts = $ this ->simulateFullVirtualReplicas ($ scope , $ scopeId );
75
-
76
73
// Get all stores affected by this configuration
77
74
$ storeIds = $ this ->configChecker ->getAffectedStoreIds (
78
75
ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED ,
79
76
$ scope ,
80
77
$ scopeId
81
78
);
82
79
80
+ // Replicate the global settings by turning on virtual replicas for all attributes and initialize based on current scope
81
+ $ virtualizedSorts = $ this ->simulateFullVirtualReplicas ($ scope , $ scopeId );
82
+
83
83
// Retrieve the sorting config
84
84
foreach ($ storeIds as $ storeId ) {
85
+ // Get the store specific sorting configuration
86
+ $ virtualizedSorts = $ this ->simulateFullVirtualReplicas (ScopeInterface::SCOPE_STORES , $ storeId );
87
+
85
88
$ sortingIndices = $ this ->sortingTransformer ->getSortingIndices ($ storeId , null , $ virtualizedSorts );
86
89
87
90
$ validator = $ this ->validatorFactory ->create ();
@@ -103,10 +106,16 @@ public function migrateSetting(string $scope = ScopeConfigInterface::SCOPE_TYPE_
103
106
}
104
107
105
108
// If all is copacetic then save the new sorting config
106
- // Save to store scope if we are not already there or if a store scope override exists
109
+ // Save to store scope if we are not already there and a store scope override exists
107
110
if ($ scope != ScopeInterface::SCOPE_STORES
108
111
&& $ this ->configChecker ->isSettingAppliedForScopeAndCode (ConfigHelper::SORTING_INDICES , ScopeInterface::SCOPE_STORES , $ storeId )) {
109
112
$ this ->configHelper ->setSorting ($ virtualizedSorts , ScopeInterface::SCOPE_STORES , $ storeId );
113
+ // If not overridden at store level next check for website overrides
114
+ } else if ($ scope != ScopeInterface::SCOPE_WEBSITES ) {
115
+ $ websiteId = $ this ->storeManager ->getStore ($ storeId )->getWebsiteId ();
116
+ if ($ this ->configChecker ->isSettingAppliedForScopeAndCode (ConfigHelper::SORTING_INDICES , ScopeInterface::SCOPE_WEBSITES , $ websiteId )) {
117
+ $ this ->configHelper ->setSorting ($ virtualizedSorts , ScopeInterface::SCOPE_WEBSITES , $ websiteId );
118
+ }
110
119
}
111
120
}
112
121
0 commit comments