32
32
use Magento \Framework \Event \ManagerInterface ;
33
33
use Magento \Store \Model \Store ;
34
34
use Magento \Store \Model \StoreManagerInterface ;
35
+ use Magento \Customer \Api \GroupExcludedWebsiteRepositoryInterface ;
35
36
36
37
class ProductHelper
37
38
{
@@ -111,6 +112,11 @@ class ProductHelper
111
112
*/
112
113
protected $ productAttributes ;
113
114
115
+ /**
116
+ * @var GroupExcludedWebsiteRepositoryInterface
117
+ */
118
+ protected $ groupExcludedWebsiteRepository ;
119
+
114
120
/**
115
121
* @var string[]
116
122
*/
@@ -164,6 +170,7 @@ class ProductHelper
164
170
* @param Type $productType
165
171
* @param CollectionFactory $productCollectionFactory
166
172
* @param GroupCollection $groupCollection
173
+ * @param GroupExcludedWebsiteRepositoryInterface groupExcludedWebsiteRepository
167
174
* @param ImageHelper $imageHelper
168
175
*/
169
176
public function __construct (
@@ -182,6 +189,7 @@ public function __construct(
182
189
Type $ productType ,
183
190
CollectionFactory $ productCollectionFactory ,
184
191
GroupCollection $ groupCollection ,
192
+ GroupExcludedWebsiteRepositoryInterface $ groupExcludedWebsiteRepository ,
185
193
ImageHelper $ imageHelper
186
194
) {
187
195
$ this ->eavConfig = $ eavConfig ;
@@ -199,6 +207,7 @@ public function __construct(
199
207
$ this ->productType = $ productType ;
200
208
$ this ->productCollectionFactory = $ productCollectionFactory ;
201
209
$ this ->groupCollection = $ groupCollection ;
210
+ $ this ->groupExcludedWebsiteRepository = $ groupExcludedWebsiteRepository ;
202
211
$ this ->imageHelper = $ imageHelper ;
203
212
}
204
213
@@ -1155,9 +1164,14 @@ protected function getAttributesForFaceting($storeId)
1155
1164
$ facet ['attribute ' ] = 'price. ' . $ currency_code . '.default ' ;
1156
1165
1157
1166
if ($ this ->configHelper ->isCustomerGroupsEnabled ($ storeId )) {
1167
+ $ websiteId = (int )$ this ->storeManager ->getStore ($ storeId )->getWebsiteId ();
1158
1168
foreach ($ this ->groupCollection as $ group ) {
1159
1169
$ group_id = (int ) $ group ->getData ('customer_group_id ' );
1160
-
1170
+ $ groupId = (int )$ group ->getData ('customer_group_id ' );
1171
+ $ excludedWebsites = $ this ->groupExcludedWebsiteRepository ->getCustomerGroupExcludedWebsites ($ groupId );
1172
+ if (in_array ($ websiteId , $ excludedWebsites )) {
1173
+ $ group ->delete ();
1174
+ }
1161
1175
$ attributesForFaceting [] = 'price. ' . $ currency_code . '.group_ ' . $ group_id ;
1162
1176
}
1163
1177
}
0 commit comments