File tree Expand file tree Collapse file tree 3 files changed +28
-23
lines changed
ConfigurableProduct/Model/Product/Type
view/base/templates/product/price Expand file tree Collapse file tree 3 files changed +28
-23
lines changed Original file line number Diff line number Diff line change @@ -1446,22 +1446,4 @@ function($attr) {
1446
1446
1447
1447
return array_unique (array_merge ($ productAttributes , $ requiredAttributes , $ usedAttributes ));
1448
1448
}
1449
-
1450
- /**
1451
- * Returns msrp for children products
1452
- *
1453
- * @param \Magento\Catalog\Model\Product $product
1454
- * @return int
1455
- */
1456
- public function getChildrenMsrp (\Magento \Catalog \Model \Product $ product )
1457
- {
1458
- $ prices = [];
1459
- foreach ($ this ->getUsedProducts ($ product ) as $ item ) {
1460
- if ($ item ->getMsrp () !== null ) {
1461
- $ prices [] = $ item ->getMsrp ();
1462
- }
1463
- }
1464
- return $ prices ? max ($ prices ) : 0 ;
1465
- }
1466
-
1467
1449
}
Original file line number Diff line number Diff line change 11
11
use Magento \Store \Model \StoreManagerInterface ;
12
12
use Magento \Catalog \Model \Product ;
13
13
use Magento \Catalog \Api \ProductRepositoryInterface ;
14
+ use Magento \ConfigurableProduct \Model \Product \Type \Configurable ;
14
15
15
16
/**
16
17
* Msrp data helper
@@ -158,11 +159,19 @@ public function isMinimalPriceLessMsrp($product)
158
159
$ msrp = $ product ->getMsrp ();
159
160
$ price = $ product ->getPriceInfo ()->getPrice (\Magento \Catalog \Pricing \Price \FinalPrice::PRICE_CODE );
160
161
if ($ msrp === null ) {
161
- if ($ product ->getTypeId () !== \Magento \GroupedProduct \Model \Product \Type \Grouped::TYPE_CODE
162
- && $ product ->getTypeId () !== \Magento \ConfigurableProduct \Model \Product \Type \Configurable::TYPE_CODE ) {
163
- return false ;
164
- } else {
162
+ if ($ product ->getTypeId () === \Magento \GroupedProduct \Model \Product \Type \Grouped::TYPE_CODE ) {
165
163
$ msrp = $ product ->getTypeInstance ()->getChildrenMsrp ($ product );
164
+ } elseif ($ product ->getTypeId () === Configurable::TYPE_CODE ) {
165
+ $ prices = [];
166
+ foreach ($ product ->getTypeInstance ()->getUsedProducts ($ product ) as $ item ) {
167
+ if ($ item ->getMsrp () !== null ) {
168
+ $ prices [] = $ item ->getMsrp ();
169
+ }
170
+ }
171
+
172
+ $ msrp = $ prices ? max ($ prices ) : 0 ;
173
+ } else {
174
+ return false ;
166
175
}
167
176
}
168
177
if ($ msrp ) {
Original file line number Diff line number Diff line change @@ -20,7 +20,21 @@ $priceType = $block->getPrice();
20
20
/** @var $product \Magento\Catalog\Model\Product */
21
21
$ product = $ block ->getSaleableItem ();
22
22
$ productId = $ product ->getId ();
23
- $ amount = $ product ->getMsrp () ?: $ product ->getTypeInstance ()->getChildrenMsrp ($ product );
23
+
24
+ $ amount = 0 ;
25
+ if ($ product ->getMsrp ()) {
26
+ $ amount = $ product ->getMsrp ();
27
+ } elseif ($ product ->getTypeId () === \Magento \GroupedProduct \Model \Product \Type \Grouped::TYPE_CODE ) {
28
+ $ amount = $ product ->getTypeInstance ()->getChildrenMsrp ($ product );
29
+ } elseif ($ product ->getTypeId () === \Magento \ConfigurableProduct \Model \Product \Type \Configurable::TYPE_CODE ) {
30
+ foreach ($ product ->getTypeInstance ()->getUsedProducts ($ product ) as $ item ) {
31
+ if ($ item ->getMsrp () !== null ) {
32
+ $ prices [] = $ item ->getMsrp ();
33
+ }
34
+ }
35
+ $ amount = $ prices ? max ($ prices ) : 0 ;
36
+ }
37
+
24
38
$ msrpPrice = $ block ->renderAmount (
25
39
$ priceType ->getCustomAmount ($ amount ),
26
40
[
You can’t perform that action at this time.
0 commit comments