10
10
use Magento \CatalogRule \Model \ResourceModel \Rule ;
11
11
use Magento \Customer \Model \Group ;
12
12
use Magento \Customer \Model \ResourceModel \Group \CollectionFactory ;
13
+ use Magento \Customer \Api \GroupExcludedWebsiteRepositoryInterface ;
13
14
use Magento \Framework \Pricing \PriceCurrencyInterface ;
14
15
use Magento \Tax \Helper \Data as TaxHelper ;
15
16
use Magento \Tax \Model \Config as TaxConfig ;
@@ -45,6 +46,11 @@ abstract class ProductWithoutChildren
45
46
*/
46
47
protected $ productloader ;
47
48
49
+ /**
50
+ * @var GroupExcludedWebsiteRepositoryInterface
51
+ */
52
+ protected $ groupExcludedWebsiteRepository ;
53
+
48
54
protected $ store ;
49
55
protected $ baseCurrencyCode ;
50
56
protected $ groups ;
@@ -54,6 +60,7 @@ abstract class ProductWithoutChildren
54
60
/**
55
61
* @param ConfigHelper $configHelper
56
62
* @param CollectionFactory $customerGroupCollectionFactory
63
+ * @param GroupExcludedWebsiteRepositoryInterface groupExcludedWebsiteRepository
57
64
* @param PriceCurrencyInterface $priceCurrency
58
65
* @param CatalogHelper $catalogHelper
59
66
* @param TaxHelper $taxHelper
@@ -63,6 +70,7 @@ abstract class ProductWithoutChildren
63
70
public function __construct (
64
71
ConfigHelper $ configHelper ,
65
72
CollectionFactory $ customerGroupCollectionFactory ,
73
+ GroupExcludedWebsiteRepositoryInterface $ groupExcludedWebsiteRepository ,
66
74
PriceCurrencyInterface $ priceCurrency ,
67
75
CatalogHelper $ catalogHelper ,
68
76
TaxHelper $ taxHelper ,
@@ -71,6 +79,7 @@ public function __construct(
71
79
) {
72
80
$ this ->configHelper = $ configHelper ;
73
81
$ this ->customerGroupCollectionFactory = $ customerGroupCollectionFactory ;
82
+ $ this ->groupExcludedWebsiteRepository = $ groupExcludedWebsiteRepository ;
74
83
$ this ->priceCurrency = $ priceCurrency ;
75
84
$ this ->catalogHelper = $ catalogHelper ;
76
85
$ this ->taxHelper = $ taxHelper ;
@@ -95,6 +104,14 @@ public function addPriceData($customData, Product $product, $subProducts): array
95
104
$ fields = $ this ->getFields ();
96
105
if (!$ this ->areCustomersGroupsEnabled ) {
97
106
$ 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
+ }
98
115
}
99
116
// price/price_with_tax => true/false
100
117
foreach ($ fields as $ field => $ withTax ) {
0 commit comments