@@ -101,23 +101,29 @@ public function execute(Observer $observer)
101101 $ productInfo [(int )$ product ->getId ()] = $ this ->adapterFactory ->create ($ product );
102102 }
103103
104- $ type = DataLoader::TYPE_OTHER ;
104+ list ($ type , $ scope ) = $ this ->detectScopeFilterAndType ($ collection );
105+
106+ $ this ->loadService ->load ($ type , $ scope , $ productInfo );
107+ }
108+
109+ public function detectScopeFilterAndType (Collection $ collection ): array
110+ {
111+ if (isset ($ this ->currentScope ) && isset ($ this ->currentType )) {
112+ $ type = $ this ->currentType ;
113+ $ scope = $ this ->currentScope ;
114+ unset($ this ->currentScope , $ this ->currentType );
115+ return [$ type , $ scope ];
116+ }
117+
105118 $ scope = $ this ->filterFactory ->createFromLimitation (
106119 (int )$ collection ->getStoreId (),
107120 $ collection ->getLimitationFilters ()
108121 );
109122
110123 if ($ collection ->getLimitationFilters ()->isUsingPriceIndex ()) {
111- $ type = DataLoader::TYPE_LIST ;
124+ return [ DataLoader::TYPE_LIST , $ scope ] ;
112125 }
113126
114- if ($ this ->currentScope && $ this ->currentType ) {
115- $ type = $ this ->currentType ;
116- $ scope = $ this ->currentScope ;
117- $ this ->currentScope = null ;
118- $ this ->currentType = null ;
119- }
120-
121- $ this ->loadService ->load ($ type , $ scope , $ productInfo );
127+ return [DataLoader::TYPE_OTHER , $ scope ];
122128 }
123129}
0 commit comments