10
10
*/
11
11
class Observer extends \Magento \Framework \Model \AbstractModel
12
12
{
13
+ /**
14
+ * Tax data
15
+ *
16
+ * @var \Magento\Tax\Helper\Data
17
+ */
18
+ protected $ _taxData ;
19
+
13
20
/**
14
21
* @var \Magento\Catalog\Model\Product\Type
15
22
*/
@@ -51,6 +58,7 @@ class Observer extends \Magento\Framework\Model\AbstractModel
51
58
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
52
59
*/
53
60
public function __construct (
61
+ \Magento \Tax \Helper \Data $ taxData ,
54
62
\Magento \Framework \Model \Context $ context ,
55
63
\Magento \Framework \Registry $ registry ,
56
64
\Magento \Framework \View \LayoutInterface $ layout ,
@@ -62,6 +70,7 @@ public function __construct(
62
70
\Magento \Framework \Data \Collection \Db $ resourceCollection = null ,
63
71
array $ data = []
64
72
) {
73
+ $ this ->_taxData = $ taxData ;
65
74
$ this ->_layout = $ layout ;
66
75
$ this ->_weeeTax = $ weeeTax ;
67
76
$ this ->_productType = $ productType ;
@@ -209,17 +218,16 @@ public function getPriceConfiguration(\Magento\Framework\Event\Observer $observe
209
218
if (is_array ($ priceConfig )) {
210
219
foreach ($ priceConfig as $ keyConfigs => $ configs ) {
211
220
if (is_array ($ configs )) {
212
- if (array_key_exists ('prices ' , $ configs )) {
213
- $ priceConfig [$ keyConfigs ]['prices ' ]['weeePrice ' ] = [
214
- 'amount ' => $ configs ['prices ' ]['finalPrice ' ]['amount ' ],
215
- ];
216
- } else {
217
- foreach ($ configs as $ keyConfig => $ config ) {
218
- $ priceConfig [$ keyConfigs ][$ keyConfig ]['prices ' ]['weeePrice ' ] = [
219
- 'amount ' => $ config ['prices ' ]['finalPrice ' ]['amount ' ],
220
- ];
221
+ foreach ($ configs as $ keyConfig => $ config ) {
222
+ $ calcPrice ='finalPrice ' ;
223
+ if ($ this ->_taxData ->priceIncludesTax () && $ this ->_taxData ->displayPriceExcludingTax ()) {
224
+ $ calcPrice ='basePrice ' ;
221
225
}
226
+ $ priceConfig [$ keyConfigs ][$ keyConfig ]['prices ' ]['weeePrice ' ]= [
227
+ 'amount ' => $ config ['prices ' ][$ calcPrice ]['amount ' ],
228
+ ];
222
229
}
230
+
223
231
}
224
232
}
225
233
}
0 commit comments