Skip to content

Commit 4b177e0

Browse files
author
Oleksandr Dubovyk
committed
Merge remote-tracking branch 'troll/MAGETWO-60283' into pull-primary
2 parents 1759088 + d2303bd commit 4b177e0

File tree

10 files changed

+289
-27
lines changed

10 files changed

+289
-27
lines changed

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Catalog\Api\ProductRepositoryInterface;
99
use Magento\Catalog\Model\Category;
10-
use Magento\Catalog\Model\Product;
1110

1211
/**
1312
* Product View block
@@ -29,6 +28,7 @@ class View extends AbstractProduct implements \Magento\Framework\DataObject\Iden
2928

3029
/**
3130
* @var \Magento\Framework\Pricing\PriceCurrencyInterface
31+
* @deprecated
3232
*/
3333
protected $priceCurrency;
3434

@@ -225,40 +225,34 @@ public function getJsonConfig()
225225
$config = [
226226
'productId' => $product->getId(),
227227
'priceFormat' => $this->_localeFormat->getPriceFormat()
228-
];
228+
];
229229
return $this->_jsonEncoder->encode($config);
230230
}
231231

232232
$tierPrices = [];
233233
$tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
234234
foreach ($tierPricesList as $tierPrice) {
235-
$tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
235+
$tierPrices[] = $tierPrice['price']->getValue();
236236
}
237237
$config = [
238-
'productId' => $product->getId(),
238+
'productId' => $product->getId(),
239239
'priceFormat' => $this->_localeFormat->getPriceFormat(),
240-
'prices' => [
241-
'oldPrice' => [
242-
'amount' => $this->priceCurrency->convert(
243-
$product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue()
244-
),
240+
'prices' => [
241+
'oldPrice' => [
242+
'amount' => $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(),
245243
'adjustments' => []
246244
],
247-
'basePrice' => [
248-
'amount' => $this->priceCurrency->convert(
249-
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount()
250-
),
245+
'basePrice' => [
246+
'amount' => $product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount(),
251247
'adjustments' => []
252248
],
253249
'finalPrice' => [
254-
'amount' => $this->priceCurrency->convert(
255-
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()
256-
),
250+
'amount' => $product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue(),
257251
'adjustments' => []
258252
]
259253
],
260-
'idSuffix' => '_clone',
261-
'tierPrices' => $tierPrices
254+
'idSuffix' => '_clone',
255+
'tierPrices' => $tierPrices
262256
];
263257

264258
$responseObject = new \Magento\Framework\DataObject();

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ public function __construct(
9292
);
9393
}
9494

95+
/**
96+
* Get cache key informative items.
97+
*
98+
* @return array
99+
*/
100+
public function getCacheKeyInfo()
101+
{
102+
$parentData = parent::getCacheKeyInfo();
103+
$parentData[] = $this->priceCurrency->getCurrencySymbol();
104+
return $parentData;
105+
}
106+
95107
/**
96108
* Get allowed attributes
97109
*

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/CustomOptions.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,22 @@
358358
</item>
359359
</field>
360360
</dataset>
361+
362+
<dataset name="not_required_text_option">
363+
<field name="0" xsi:type="array">
364+
<item name="title" xsi:type="string">Test1 option %isolation%</item>
365+
<item name="is_require" xsi:type="string">No</item>
366+
<item name="type" xsi:type="string">Text/Field</item>
367+
<item name="options" xsi:type="array">
368+
<item name="0" xsi:type="array">
369+
<item name="price" xsi:type="string">10</item>
370+
<item name="price_type" xsi:type="string">Fixed</item>
371+
<item name="sku" xsi:type="string">sku1_%isolation%</item>
372+
<item name="max_characters" xsi:type="string">45</item>
373+
</item>
374+
</item>
375+
</field>
376+
</dataset>
377+
361378
</repository>
362379
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ConfigurableProduct\Test\Constraint;
8+
9+
use Magento\Catalog\Test\Page\Product\CatalogProductView;
10+
use Magento\Cms\Test\Page\CmsIndex;
11+
use Magento\CurrencySymbol\Test\Fixture\CurrencySymbolEntity;
12+
use Magento\Mtf\Client\BrowserInterface;
13+
use Magento\Mtf\Constraint\AbstractConstraint;
14+
use Magento\Mtf\Fixture\InjectableFixture;
15+
16+
/**
17+
* Assert currency rate applied on configurable product page.
18+
*/
19+
class AssertCurrencyRateAppliedOnProductPage extends AbstractConstraint
20+
{
21+
/**
22+
* Assert currency rate applied on configurable product page.
23+
*
24+
* @param BrowserInterface $browser
25+
* @param InjectableFixture $product
26+
* @param CatalogProductView $view
27+
* @param CmsIndex $cmsIndex
28+
* @param CurrencySymbolEntity $baseCurrency
29+
* @param array $configuredPrices
30+
* @param string $basePrice
31+
*/
32+
public function processAssert(
33+
BrowserInterface $browser,
34+
InjectableFixture $product,
35+
CatalogProductView $view,
36+
CmsIndex $cmsIndex,
37+
CurrencySymbolEntity $baseCurrency,
38+
array $configuredPrices,
39+
$basePrice
40+
) {
41+
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
42+
$this->assertPrice($view, $basePrice);
43+
44+
$view->getViewBlock()->configure($product);
45+
$this->assertPrice($view, $configuredPrices['custom_currency']);
46+
47+
$cmsIndex->getCurrencyBlock()->switchCurrency($baseCurrency);
48+
$view->getViewBlock()->configure($product);
49+
$this->assertPrice($view, $configuredPrices['base_currency']);
50+
}
51+
52+
/**
53+
* Assert price.
54+
*
55+
* @param CatalogProductView $view
56+
* @param string $price
57+
* @param string $currency [optional]
58+
*/
59+
public function assertPrice(CatalogProductView $view, $price, $currency = '')
60+
{
61+
\PHPUnit_Framework_Assert::assertEquals(
62+
$price,
63+
$view->getViewBlock()->getPriceBlock()->getPrice($currency),
64+
'Wrong price is displayed on Product page.'
65+
);
66+
}
67+
68+
/**
69+
* Returns a string representation of successful assertion.
70+
*
71+
* @return string
72+
*/
73+
public function toString()
74+
{
75+
return "Currency rate has been applied correctly on Configurable Product page.";
76+
}
77+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Directory\Test\TestCase\CreateCurrencyRateTest" summary="Create Currency Rate" ticketId="MAGETWO-36824">
10+
<variation name="CreateCurrencyRateTestVariation3">
11+
<data name="currencyRate/data/currency_from" xsi:type="string">USD</data>
12+
<data name="currencyRate/data/currency_to" xsi:type="string">UAH</data>
13+
<data name="currencyRate/data/rate" xsi:type="number">2.000</data>
14+
<data name="currencySymbol/dataSet" xsi:type="string">currency_symbols_uah</data>
15+
<data name="product" xsi:type="string">configurableProduct::default</data>
16+
<data name="config/dataset" xsi:type="string">config_base_currency_us_display_currency_uah</data>
17+
<data name="baseCurrency/data/code" xsi:type="string">USD</data>
18+
<data name="basePrice" xsi:type="string">₴80.00</data>
19+
<data name="configuredPrices" xsi:type="array">
20+
<item name="custom_currency" xsi:type="string">₴80.00</item>
21+
<item name="base_currency" xsi:type="string">$40.00</item>
22+
</data>
23+
<data name="tag" xsi:type="string">test_type:acceptance_test</data>
24+
<constraint name="Magento\Directory\Test\Constraint\AssertCurrencyRateSuccessSaveMessage" />
25+
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertCurrencyRateAppliedOnProductPage" />
26+
</variation>
27+
</testCase>
28+
</config>

dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@
4848
<item name="US Dollar" xsi:type="string">USD</item>
4949
</item>
5050
</field>
51+
<field name="currency/options/base" xsi:type="array">
52+
<item name="scope" xsi:type="string">currency</item>
53+
<item name="label" xsi:type="string">US Dollar</item>
54+
<item name="scope_id" xsi:type="number">1</item>
55+
<item name="value" xsi:type="string">USD</item>
56+
</field>
57+
<field name="currency/options/default" xsi:type="array">
58+
<item name="scope" xsi:type="string">currency</item>
59+
<item name="label" xsi:type="string">US Dollar</item>
60+
<item name="scope_id" xsi:type="number">1</item>
61+
<item name="value" xsi:type="string">USD</item>
62+
</field>
5163
</dataset>
5264

5365
<dataset name="config_base_currency_ch">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Directory\Test\Constraint;
8+
9+
use Magento\Catalog\Test\Page\Product\CatalogProductView;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
use Magento\Mtf\Fixture\InjectableFixture;
13+
14+
/**
15+
* Assert currency rate applied on product page.
16+
*/
17+
class AssertCurrencyRateAppliedOnProductPage extends AbstractConstraint
18+
{
19+
/**
20+
* Assert currency rate applied on product page.
21+
*
22+
* @param BrowserInterface $browser
23+
* @param InjectableFixture $product
24+
* @param CatalogProductView $view
25+
* @param string $basePrice
26+
*/
27+
public function processAssert(
28+
BrowserInterface $browser,
29+
InjectableFixture $product,
30+
CatalogProductView $view,
31+
$basePrice
32+
) {
33+
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
34+
$this->assertPrice($view, $basePrice);
35+
}
36+
37+
/**
38+
* Assert price.
39+
*
40+
* @param CatalogProductView $view
41+
* @param string $price
42+
* @param string $currency [optional]
43+
*/
44+
public function assertPrice(CatalogProductView $view, $price, $currency = '')
45+
{
46+
\PHPUnit_Framework_Assert::assertEquals(
47+
$price,
48+
$view->getViewBlock()->getPriceBlock()->getPrice($currency),
49+
'Wrong price is displayed on Product page.'
50+
);
51+
}
52+
53+
/**
54+
* Returns a string representation of successful assertion.
55+
*
56+
* @return string
57+
*/
58+
public function toString()
59+
{
60+
return "Currency rate has been applied correctly on Product page.";
61+
}
62+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9+
<repository class="Magento\Config\Test\Repository\ConfigData">
10+
<dataset name="config_base_currency_us_display_currency_uah">
11+
<field name="currency/options/allow" xsi:type="array">
12+
<item name="scope" xsi:type="string">currency</item>
13+
<item name="scope_id" xsi:type="number">1</item>
14+
<item name="value" xsi:type="array">
15+
<item name="Ukrainian Hryvnia" xsi:type="string">UAH</item>
16+
<item name="US Dollar" xsi:type="string">USD</item>
17+
</item>
18+
</field>
19+
<field name="currency/options/base" xsi:type="array">
20+
<item name="scope" xsi:type="string">currency</item>
21+
<item name="label" xsi:type="string">US Dollar</item>
22+
<item name="scope_id" xsi:type="number">1</item>
23+
<item name="value" xsi:type="string">USD</item>
24+
</field>
25+
<field name="currency/options/default" xsi:type="array">
26+
<item name="scope" xsi:type="string">currency</item>
27+
<item name="label" xsi:type="string">Ukrainian Hryvnia</item>
28+
<item name="scope_id" xsi:type="number">1</item>
29+
<item name="value" xsi:type="string">UAH</item>
30+
</field>
31+
</dataset>
32+
</repository>
33+
</config>

0 commit comments

Comments
 (0)