@@ -87,20 +87,53 @@ protected function execute(InputInterface $input, OutputInterface $output): int
87
87
*/
88
88
protected function disableVirtualReplicas (array $ storeIds = []): void
89
89
{
90
+ $ updates = [];
90
91
if (count ($ storeIds )) {
91
92
foreach ($ storeIds as $ storeId ) {
92
- $ this ->disableVirtualReplicasForStore ($ storeId );
93
+ if ($ this ->disableVirtualReplicasForStore ($ storeId )) {
94
+ $ updates [] = $ storeId ;
95
+ }
96
+ }
97
+ if ($ updates ) {
98
+ $ this ->clearCache ();
99
+ foreach ($ updates as $ storeId ) {
100
+ $ this ->syncReplicasForStore ($ storeId );
101
+ }
93
102
}
94
103
} else {
95
104
$ this ->disableVirtualReplicasForAllStores ();
96
105
}
97
106
}
98
107
99
- protected function disableVirtualReplicasForStore (int $ storeId ): void
108
+ protected function disableVirtualReplicasForStore (int $ storeId ): bool
100
109
{
101
110
$ storeName = $ this ->storeNameFetcher ->getStoreName ($ storeId );
102
111
$ isStoreScoped = false ;
103
112
113
+ if ($ this ->configChecker ->isSettingAppliedForScopeAndCode (
114
+ ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED ,
115
+ ScopeInterface::SCOPE_STORES ,
116
+ $ storeId )
117
+ ) {
118
+ $ isStoreScoped = true ;
119
+ $ this ->removeLegacyVirtualReplicaConfig (ScopeInterface::SCOPE_STORES , $ storeId );
120
+ }
121
+
122
+ if ($ this ->configChecker ->isSettingAppliedForScopeAndCode (
123
+ ConfigHelper::SORTING_INDICES ,
124
+ ScopeInterface::SCOPE_STORES ,
125
+ $ storeId )
126
+ ) {
127
+ $ isStoreScoped = true ;
128
+ $ this ->disableVirtualReplicaSortConfig (ScopeInterface::SCOPE_STORES , $ storeId );
129
+ }
130
+
131
+ if (!$ isStoreScoped ) {
132
+ $ this ->output ->writeln ("<info>Virtual replicas are not configured at the store level for $ storeName. You will need to re-run this command for all stores.</info> " );
133
+ return false ;
134
+ }
135
+
136
+ return true ;
104
137
}
105
138
106
139
protected function disableVirtualReplicasForAllStores (): void
@@ -109,7 +142,7 @@ protected function disableVirtualReplicasForAllStores(): void
109
142
110
143
$ this ->configChecker ->checkAndApplyAllScopes (ConfigHelper::SORTING_INDICES , [$ this , 'disableVirtualReplicaSortConfig ' ]);
111
144
112
- $ this ->cacheManager -> clean ([ ' config ' ] );
145
+ $ this ->clearCache ( );
113
146
114
147
$ this ->syncReplicasForAllStores ();
115
148
}
@@ -141,4 +174,9 @@ function($sort) {
141
174
$ this ->configHelper ->setSorting ($ sorting , $ scope , $ scopeId );
142
175
}
143
176
177
+ protected function clearCache (): void
178
+ {
179
+ $ this ->cacheManager ->clean (['config ' ]);
180
+ }
181
+
144
182
}
0 commit comments