11
11
use Magento \Framework \Serialize \SerializerInterface ;
12
12
use Magento \Store \Model \ScopeInterface ;
13
13
use Magento \Store \Model \StoreManagerInterface ;
14
+ use Magento \Customer \Api \GroupExcludedWebsiteRepositoryInterface ;
14
15
15
16
class ConfigHelper
16
17
{
@@ -175,6 +176,11 @@ class ConfigHelper
175
176
*/
176
177
protected $ groupCollection ;
177
178
179
+ /**
180
+ * @var GroupExcludedWebsiteRepositoryInterface
181
+ */
182
+ protected $ groupExcludedWebsiteRepository ;
183
+
178
184
/**
179
185
* @param Magento\Framework\App\Config\ScopeConfigInterface $configInterface
180
186
* @param StoreManagerInterface $storeManager
@@ -186,6 +192,7 @@ class ConfigHelper
186
192
* @param Magento\Framework\Event\ManagerInterface $eventManager
187
193
* @param SerializerInterface $serializer
188
194
* @param GroupCollection $groupCollection
195
+ * @param GroupExcludedWebsiteRepositoryInterface $groupExcludedWebsiteRepository
189
196
*/
190
197
public function __construct (
191
198
Magento \Framework \App \Config \ScopeConfigInterface $ configInterface ,
@@ -197,7 +204,8 @@ public function __construct(
197
204
Magento \Framework \App \ProductMetadataInterface $ productMetadata ,
198
205
Magento \Framework \Event \ManagerInterface $ eventManager ,
199
206
SerializerInterface $ serializer ,
200
- GroupCollection $ groupCollection
207
+ GroupCollection $ groupCollection ,
208
+ GroupExcludedWebsiteRepositoryInterface $ groupExcludedWebsiteRepository
201
209
) {
202
210
$ this ->configInterface = $ configInterface ;
203
211
$ this ->currency = $ currency ;
@@ -209,6 +217,7 @@ public function __construct(
209
217
$ this ->eventManager = $ eventManager ;
210
218
$ this ->serializer = $ serializer ;
211
219
$ this ->groupCollection = $ groupCollection ;
220
+ $ this ->groupExcludedWebsiteRepository = $ groupExcludedWebsiteRepository ;
212
221
}
213
222
214
223
/**
@@ -939,12 +948,17 @@ public function getSortingIndices($originalIndexName, $storeId = null, $currentC
939
948
$ indexName = false ;
940
949
$ sortAttribute = false ;
941
950
if ($ this ->isCustomerGroupsEnabled ($ storeId ) && $ attr ['attribute ' ] === 'price ' ) {
951
+ $ websiteId = (int )$ this ->storeManager ->getStore ($ storeId )->getWebsiteId ();
942
952
$ groupCollection = $ this ->groupCollection ;
943
953
if (!is_null ($ currentCustomerGroupId )) {
944
954
$ groupCollection ->addFilter ('customer_group_id ' , $ currentCustomerGroupId );
945
955
}
946
956
foreach ($ groupCollection as $ group ) {
947
957
$ customerGroupId = (int )$ group ->getData ('customer_group_id ' );
958
+ $ excludedWebsites = $ this ->groupExcludedWebsiteRepository ->getCustomerGroupExcludedWebsites ($ customerGroupId );
959
+ if (in_array ($ websiteId , $ excludedWebsites )) {
960
+ continue ;
961
+ }
948
962
$ groupIndexNameSuffix = 'group_ ' . $ customerGroupId ;
949
963
$ groupIndexName =
950
964
$ originalIndexName . '_ ' . $ attr ['attribute ' ] . '_ ' . $ groupIndexNameSuffix . '_ ' . $ attr ['sort ' ];
0 commit comments