This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +72
-76
lines changed
Model/Product/Pricing/Renderer
Plugin/Catalog/Model/Product/Pricing/Renderer
dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint Expand file tree Collapse file tree 6 files changed +72
-76
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \ConfigurableProduct \Plugin \Catalog \Model \Product \Pricing \Renderer ;
7
+
8
+ use Magento \ConfigurableProduct \Pricing \Price \LowestPriceOptionsProviderInterface ;
9
+
10
+ /**
11
+ * A plugin for a salable resolver.
12
+ */
13
+ class SalableResolver
14
+ {
15
+ /**
16
+ * @var LowestPriceOptionsProviderInterface
17
+ */
18
+ private $ lowestPriceOptionsProvider ;
19
+
20
+ /**
21
+ * @param LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
22
+ */
23
+ public function __construct (
24
+ LowestPriceOptionsProviderInterface $ lowestPriceOptionsProvider
25
+ ) {
26
+ $ this ->lowestPriceOptionsProvider = $ lowestPriceOptionsProvider ;
27
+ }
28
+
29
+ /**
30
+ * Performs an additional check whether given configurable product has
31
+ * at least one configuration in-stock.
32
+ *
33
+ * @param \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject
34
+ * @param bool $result
35
+ * @param \Magento\Framework\Pricing\SaleableInterface $salableItem
36
+ *
37
+ * @return bool
38
+ *
39
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
40
+ */
41
+ public function afterIsSalable (
42
+ \Magento \Catalog \Model \Product \Pricing \Renderer \SalableResolver $ subject ,
43
+ $ result ,
44
+ \Magento \Framework \Pricing \SaleableInterface $ salableItem
45
+ ) {
46
+ if ($ salableItem ->getTypeId () == 'configurable ' && $ result ) {
47
+ if (!$ this ->lowestPriceOptionsProvider ->getProducts ($ salableItem )) {
48
+ $ result = false ;
49
+ }
50
+ }
51
+
52
+ return $ result ;
53
+ }
54
+ }
Original file line number Diff line number Diff line change 206
206
<argument name =" baseSelectProcessor" xsi : type =" object" >Magento\ConfigurableProduct\Model\ResourceModel\Product\StockStatusBaseSelectProcessor</argument >
207
207
</arguments >
208
208
</type >
209
- <type name =" Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox" >
210
- <arguments >
211
- <argument name =" salableResolver" xsi : type =" object" >Magento\ConfigurableProduct\Model\Product\Pricing\Renderer\SalableResolver</argument >
212
- </arguments >
209
+ <type name =" Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver" >
210
+ <plugin name =" configurable" type =" Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer\SalableResolver" />
213
211
</type >
214
212
</config >
Original file line number Diff line number Diff line change 78
78
</argument >
79
79
</arguments >
80
80
</type >
81
- <virtualType name =" Magento\Wishlist\Pricing\Render\Configurable\ConfiguredPriceBox" type =" Magento\Wishlist\Pricing\Render\ConfiguredPriceBox" >
82
- <arguments >
83
- <argument name =" salableResolver" xsi : type =" object" >Magento\ConfigurableProduct\Model\Product\Pricing\Renderer\SalableResolver</argument >
84
- </arguments >
85
- </virtualType >
86
81
</config >
Original file line number Diff line number Diff line change 16
16
</item >
17
17
</item >
18
18
</argument >
19
- <argument name =" configurable" xsi : type =" array" >
20
- <item name =" prices" xsi : type =" array" >
21
- <item name =" wishlist_configured_price" xsi : type =" array" >
22
- <item name =" render_class" xsi : type =" string" >Magento\Wishlist\Pricing\Render\Configurable\ConfiguredPriceBox</item >
23
- </item >
24
- </item >
25
- </argument >
26
19
</arguments >
27
20
</referenceBlock >
28
21
</layout >
Original file line number Diff line number Diff line change @@ -30,16 +30,25 @@ protected function verify()
30
30
protected function verifyPrice ()
31
31
{
32
32
$ priceBlock = $ this ->productView ->getPriceBlock ();
33
- if (!$ priceBlock ->isVisible ()) {
34
- return "Price block for ' {$ this ->product ->getName ()}' product' is not visible. " ;
35
- }
36
- $ formPrice = $ priceBlock ->isOldPriceVisible () ? $ priceBlock ->getOldPrice () : $ priceBlock ->getPrice ();
37
33
$ fixturePrice = $ this ->getLowestConfigurablePrice ();
38
34
39
- if ($ fixturePrice != $ formPrice ) {
40
- return "Displayed product price on product page (front-end) not equals passed from fixture. "
41
- . "Actual: {$ formPrice }, expected: {$ fixturePrice }. " ;
35
+ if ($ fixturePrice === null ) {
36
+ if ($ priceBlock ->isVisible ()) {
37
+ return "Price block for ' {$ this ->product ->getName ()}' product' is visible. " ;
38
+ }
39
+ } else {
40
+ if (!$ priceBlock ->isVisible ()) {
41
+ return "Price block for ' {$ this ->product ->getName ()}' product' is not visible. " ;
42
+ }
43
+
44
+ $ formPrice = $ priceBlock ->isOldPriceVisible () ? $ priceBlock ->getOldPrice () : $ priceBlock ->getPrice ();
45
+
46
+ if ($ fixturePrice != $ formPrice ) {
47
+ return "Displayed product price on product page (front-end) not equals passed from fixture. "
48
+ . "Actual: {$ formPrice }, expected: {$ fixturePrice }. " ;
49
+ }
42
50
}
51
+
43
52
return null ;
44
53
}
45
54
You can’t perform that action at this time.
0 commit comments