Skip to content

Commit 3f26b62

Browse files
committed
Fixed Indexer created for websites excluded in Customer groups
1 parent 2a4e068 commit 3f26b62

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Helper/Entity/Product/PriceManager/ProductWithoutChildren.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\CatalogRule\Model\ResourceModel\Rule;
1111
use Magento\Customer\Model\Group;
1212
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
13+
use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface;
1314
use Magento\Framework\Pricing\PriceCurrencyInterface;
1415
use Magento\Tax\Helper\Data as TaxHelper;
1516
use Magento\Tax\Model\Config as TaxConfig;
@@ -45,6 +46,11 @@ abstract class ProductWithoutChildren
4546
*/
4647
protected $productloader;
4748

49+
/**
50+
* @var GroupExcludedWebsiteRepositoryInterface
51+
*/
52+
protected $groupExcludedWebsiteRepository;
53+
4854
protected $store;
4955
protected $baseCurrencyCode;
5056
protected $groups;
@@ -54,6 +60,7 @@ abstract class ProductWithoutChildren
5460
/**
5561
* @param ConfigHelper $configHelper
5662
* @param CollectionFactory $customerGroupCollectionFactory
63+
* @param GroupExcludedWebsiteRepositoryInterface groupExcludedWebsiteRepository
5764
* @param PriceCurrencyInterface $priceCurrency
5865
* @param CatalogHelper $catalogHelper
5966
* @param TaxHelper $taxHelper
@@ -63,6 +70,7 @@ abstract class ProductWithoutChildren
6370
public function __construct(
6471
ConfigHelper $configHelper,
6572
CollectionFactory $customerGroupCollectionFactory,
73+
GroupExcludedWebsiteRepositoryInterface $groupExcludedWebsiteRepository,
6674
PriceCurrencyInterface $priceCurrency,
6775
CatalogHelper $catalogHelper,
6876
TaxHelper $taxHelper,
@@ -71,6 +79,7 @@ public function __construct(
7179
) {
7280
$this->configHelper = $configHelper;
7381
$this->customerGroupCollectionFactory = $customerGroupCollectionFactory;
82+
$this->groupExcludedWebsiteRepository = $groupExcludedWebsiteRepository;
7483
$this->priceCurrency = $priceCurrency;
7584
$this->catalogHelper = $catalogHelper;
7685
$this->taxHelper = $taxHelper;
@@ -95,6 +104,14 @@ public function addPriceData($customData, Product $product, $subProducts): array
95104
$fields = $this->getFields();
96105
if (!$this->areCustomersGroupsEnabled) {
97106
$this->groups->addFieldToFilter('main_table.customer_group_id', 0);
107+
} else {
108+
foreach ($this->groups as $group) {
109+
$groupId = (int)$group->getData('customer_group_id');
110+
$excludedWebsites = $this->groupExcludedWebsiteRepository->getCustomerGroupExcludedWebsites($groupId);
111+
if (in_array($product->getStore()->getWebsiteId(), $excludedWebsites)) {
112+
$group->delete();
113+
}
114+
}
98115
}
99116
// price/price_with_tax => true/false
100117
foreach ($fields as $field => $withTax) {

0 commit comments

Comments
 (0)