Skip to content

Commit 89dada6

Browse files
author
Dmytro Vilchynskyi
committed
MAGETWO-71515: Special/lowest price in child of a Configurable Product causes the entire product to show that price
- FAT
1 parent ddbb8b6 commit 89dada6

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
*/
1717
class ListCompare extends Block
1818
{
19+
/**
20+
* Price displaying format.
21+
*
22+
* @var int
23+
*/
24+
protected $priceFormat = 2;
25+
1926
/**
2027
* Selector by product info.
2128
*
@@ -101,11 +108,7 @@ public function getProductInfo($index, $attributeKey, $currency = ' $')
101108
$price = $infoBlock->find($this->priceSelector, Locator::SELECTOR_XPATH)->getText();
102109
preg_match_all('`([a-z]+).*?([\d\.]+)`i', $price, $prices);
103110
if (!empty($prices[0])) {
104-
$resultPrice = [];
105-
foreach ($prices[1] as $key => $value) {
106-
$resultPrice['price_' . lcfirst($value)] = $prices[2][$key];
107-
}
108-
return $resultPrice;
111+
return number_format(end($prices)[0], $this->priceFormat);
109112
}
110113
return trim($price, $currency);
111114
} else {

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductComparePage.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
*/
1717
class AssertProductComparePage extends AbstractConstraint
1818
{
19+
/**
20+
* Price displaying format.
21+
*
22+
* @var int
23+
*/
24+
protected $priceFormat = 2;
25+
1926
/**
2027
* Product attribute on compare product page
2128
*
@@ -30,8 +37,8 @@ class AssertProductComparePage extends AbstractConstraint
3037
];
3138

3239
/**
33-
* Assert that "Compare Product" page contains product(s) that was added
34-
* - Product name
40+
* Assert that "Compare Product" Storefront page contains added Products with expected Attribute values:
41+
* - Name
3542
* - Price
3643
* - SKU
3744
* - Description (if exists, else text "No")
@@ -56,19 +63,23 @@ public function processAssert(
5663
$value = $attribute;
5764
$attribute = is_numeric($attributeKey) ? $attribute : $attributeKey;
5865

59-
$attributeValue = $attribute != 'price'
66+
$expectedAttributeValue = $attribute != 'price'
6067
? ($product->hasData($attribute)
6168
? $product->getData($attribute)
6269
: 'N/A')
6370
: ($product->getDataFieldConfig('price')['source']->getPriceData() !== null
6471
? $product->getDataFieldConfig('price')['source']->getPriceData()['compare_price']
65-
: number_format($product->getPrice(), 2));
72+
: number_format($product->getPrice(), $this->priceFormat));
6673

6774
$attribute = is_numeric($attributeKey) ? 'info' : 'attribute';
75+
$attribute = ucfirst($attribute);
76+
$actualAttributeValue =
77+
$comparePage->getCompareProductsBlock()->{'getProduct' . $attribute}($key + 1, $value);
78+
6879
\PHPUnit_Framework_Assert::assertEquals(
69-
$attributeValue,
70-
$comparePage->getCompareProductsBlock()->{'getProduct' . ucfirst($attribute)}($key + 1, $value),
71-
'Product "' . $product->getName() . '" is\'n equals with data from fixture.'
80+
$expectedAttributeValue,
81+
$actualAttributeValue,
82+
'Product "' . $product->getName() . '" has "' . $attribute . '" value different from fixture one.'
7283
);
7384
}
7485
}

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
</dataset>
1313
<dataset name="price_40">
1414
<field name="category_price" xsi:type="string">40</field>
15-
<field name="compare_price" xsi:type="string">40</field>
15+
<field name="compare_price" xsi:type="string">40.00</field>
1616
</dataset>
1717
<dataset name="MAGETWO-12620">
1818
<field name="category_price" xsi:type="string">11</field>
1919
</dataset>
2020
<dataset name="price_15">
2121
<field name="category_price" xsi:type="string">15</field>
22-
<field name="compare_price" xsi:type="string">15</field>
22+
<field name="compare_price" xsi:type="string">15.00</field>
2323
</dataset>
2424
</repository>
2525
</config>

0 commit comments

Comments
 (0)