Skip to content

Commit 7611eff

Browse files
committed
Fix for Indexer created for websites excluded in Customer groups
1 parent 3f26b62 commit 7611eff

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Helper/Entity/ProductHelper.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Magento\Framework\Event\ManagerInterface;
3333
use Magento\Store\Model\Store;
3434
use Magento\Store\Model\StoreManagerInterface;
35+
use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface;
3536

3637
class ProductHelper
3738
{
@@ -111,6 +112,11 @@ class ProductHelper
111112
*/
112113
protected $productAttributes;
113114

115+
/**
116+
* @var GroupExcludedWebsiteRepositoryInterface
117+
*/
118+
protected $groupExcludedWebsiteRepository;
119+
114120
/**
115121
* @var string[]
116122
*/
@@ -164,6 +170,7 @@ class ProductHelper
164170
* @param Type $productType
165171
* @param CollectionFactory $productCollectionFactory
166172
* @param GroupCollection $groupCollection
173+
* @param GroupExcludedWebsiteRepositoryInterface groupExcludedWebsiteRepository
167174
* @param ImageHelper $imageHelper
168175
*/
169176
public function __construct(
@@ -182,6 +189,7 @@ public function __construct(
182189
Type $productType,
183190
CollectionFactory $productCollectionFactory,
184191
GroupCollection $groupCollection,
192+
GroupExcludedWebsiteRepositoryInterface $groupExcludedWebsiteRepository,
185193
ImageHelper $imageHelper
186194
) {
187195
$this->eavConfig = $eavConfig;
@@ -199,6 +207,7 @@ public function __construct(
199207
$this->productType = $productType;
200208
$this->productCollectionFactory = $productCollectionFactory;
201209
$this->groupCollection = $groupCollection;
210+
$this->groupExcludedWebsiteRepository = $groupExcludedWebsiteRepository;
202211
$this->imageHelper = $imageHelper;
203212
}
204213

@@ -1155,9 +1164,14 @@ protected function getAttributesForFaceting($storeId)
11551164
$facet['attribute'] = 'price.' . $currency_code . '.default';
11561165

11571166
if ($this->configHelper->isCustomerGroupsEnabled($storeId)) {
1167+
$websiteId = (int)$this->storeManager->getStore($storeId)->getWebsiteId();
11581168
foreach ($this->groupCollection as $group) {
11591169
$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+
}
11611175
$attributesForFaceting[] = 'price.' . $currency_code . '.group_' . $group_id;
11621176
}
11631177
}

0 commit comments

Comments
 (0)