Skip to content

Commit c878f39

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-77850' into 2.3-develop-pr10-2
2 parents f68ad83 + 4f7d328 commit c878f39

File tree

14 files changed

+239
-41
lines changed

14 files changed

+239
-41
lines changed

app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ $finalPriceModel = $block->getPriceType('final_price');
1919
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
2020
$schema = ($block->getZone() == 'item_view') ? true : false;
2121
?>
22+
<span class="normal-price">
23+
<?php
24+
$arguments = [
25+
'display_label' => __('As low as'),
26+
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
27+
'price_type' => 'finalPrice',
28+
'include_container' => true,
29+
'schema' => $schema,
30+
];
31+
/* @noEscape */ echo $block->renderAmount($finalPriceModel->getAmount(), $arguments);
32+
?>
33+
</span>
34+
2235
<?php if (!$block->isProductList() && $block->hasSpecialPrice()): ?>
23-
<span class="special-price">
24-
<?php /* @escapeNotVerified */ echo $block->renderAmount($finalPriceModel->getAmount(), [
25-
'display_label' => __('Special Price'),
26-
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
27-
'price_type' => 'finalPrice',
28-
'include_container' => true,
29-
'schema' => $schema
30-
]); ?>
31-
</span>
3236
<span class="old-price sly-old-price no-display">
3337
<?php /* @escapeNotVerified */ echo $block->renderAmount($priceModel->getAmount(), [
3438
'display_label' => __('Regular Price'),
@@ -38,13 +42,6 @@ $schema = ($block->getZone() == 'item_view') ? true : false;
3842
'skip_adjustments' => true
3943
]); ?>
4044
</span>
41-
<?php else: ?>
42-
<?php /* @escapeNotVerified */ echo $block->renderAmount($finalPriceModel->getAmount(), [
43-
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
44-
'price_type' => 'finalPrice',
45-
'include_container' => true,
46-
'schema' => $schema
47-
]); ?>
4845
<?php endif; ?>
4946

5047
<?php if ($block->showMinimalPrice()): ?>

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ define([
3232
mediaGallerySelector: '[data-gallery-role=gallery-placeholder]',
3333
mediaGalleryInitial: null,
3434
slyOldPriceSelector: '.sly-old-price',
35+
normalPriceLabelSelector: '.normal-price .price-label',
3536

3637
/**
3738
* Defines the mechanism of how images of a gallery should be
@@ -269,6 +270,7 @@ define([
269270
this._reloadPrice();
270271
this._displayRegularPriceBlock(this.simpleProduct);
271272
this._displayTierPriceBlock(this.simpleProduct);
273+
this._displayNormalPriceLabel();
272274
this._changeProductImage();
273275
},
274276

@@ -527,8 +529,16 @@ define([
527529
* @private
528530
*/
529531
_displayRegularPriceBlock: function (optionId) {
530-
if (typeof optionId != 'undefined' &&
531-
this.options.spConfig.optionPrices[optionId].oldPrice.amount != //eslint-disable-line eqeqeq
532+
var shouldBeShown = true;
533+
534+
_.each(this.options.settings, function (element) {
535+
if (element.value === '') {
536+
shouldBeShown = false;
537+
}
538+
});
539+
540+
if (shouldBeShown &&
541+
this.options.spConfig.optionPrices[optionId].oldPrice.amount !==
532542
this.options.spConfig.optionPrices[optionId].finalPrice.amount
533543
) {
534544
$(this.options.slyOldPriceSelector).show();
@@ -537,6 +547,27 @@ define([
537547
}
538548
},
539549

550+
/**
551+
* Show or hide normal price label
552+
*
553+
* @private
554+
*/
555+
_displayNormalPriceLabel: function () {
556+
var shouldBeShown = false;
557+
558+
_.each(this.options.settings, function (element) {
559+
if (element.value === '') {
560+
shouldBeShown = true;
561+
}
562+
});
563+
564+
if (shouldBeShown) {
565+
$(this.options.normalPriceLabelSelector).show();
566+
} else {
567+
$(this.options.normalPriceLabelSelector).hide();
568+
}
569+
},
570+
540571
/**
541572
* Callback which fired after gallery gets initialized.
542573
*

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ define([
268268
// tier prise selectors start
269269
tierPriceTemplateSelector: '#tier-prices-template',
270270
tierPriceBlockSelector: '[data-role="tier-price-block"]',
271-
tierPriceTemplate: ''
271+
tierPriceTemplate: '',
272272
// tier prise selectors end
273+
274+
// A price label selector
275+
normalPriceLabelSelector: '.normal-price .price-label'
273276
},
274277

275278
/**
@@ -924,6 +927,22 @@ define([
924927
} else {
925928
$(this.options.tierPriceBlockSelector).hide();
926929
}
930+
931+
$(this.options.normalPriceLabelSelector).hide();
932+
933+
_.each($('.' + this.options.classes.attributeOptionsWrapper), function (attribute) {
934+
if ($(attribute).find('.' + this.options.classes.optionClass + '.selected').length === 0) {
935+
if ($(attribute).find('.' + this.options.classes.selectClass).length > 0) {
936+
_.each($(attribute).find('.' + this.options.classes.selectClass), function (dropdown) {
937+
if ($(dropdown).val() === '0') {
938+
$(this.options.normalPriceLabelSelector).show();
939+
}
940+
}.bind(this));
941+
} else {
942+
$(this.options.normalPriceLabelSelector).show();
943+
}
944+
}
945+
}.bind(this));
927946
},
928947

929948
/**

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,23 @@ public function getThresholdMessage()
243243
/**
244244
* Get block price.
245245
*
246+
* @param FixtureInterface|null $product
247+
*
246248
* @return Price
247249
*/
248-
public function getPriceBlock()
250+
public function getPriceBlock(FixtureInterface $product = null)
249251
{
252+
$typeId = '';
253+
254+
if ($product) {
255+
$dataConfig = $product->getDataConfig();
256+
$typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
257+
}
258+
259+
if ($this->hasRender($typeId)) {
260+
return $this->callRender($typeId, 'getPriceBlock');
261+
}
262+
250263
return $this->blockFactory->create(
251264
\Magento\Catalog\Test\Block\Product\Price::class,
252265
['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)]

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+
private $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/Catalog/Test/Constraint/AssertProductPage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ protected function verifySpecialPrice()
145145
}
146146
$expectedSpecialPrice = $this->product->getSpecialPrice();
147147
$expectedSpecialPrice = number_format($expectedSpecialPrice, 2);
148-
$priceBlock = $this->productView->getPriceBlock();
148+
$priceBlock = $this->productView->getPriceBlock($this->product);
149149
if (!$priceBlock->isVisible()) {
150150
return "Price block for '{$this->product->getName()}' product' is not visible.";
151151
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function setErrorMessage($errorMessage)
6464
public function assertPrice(FixtureInterface $product, View $productViewBlock)
6565
{
6666
$fields = $product->getData();
67-
$specialPrice = $productViewBlock->getPriceBlock()->getSpecialPrice();
67+
$specialPrice = $productViewBlock->getPriceBlock($product)->getSpecialPrice();
6868
if (isset($fields['special_price'])) {
6969
\PHPUnit\Framework\Assert::assertEquals(
7070
number_format($fields['special_price'], 2),

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/AddCompareProductsTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
<constraint name="Magento\Catalog\Test\Constraint\AssertProductComparePage" />
2222
</variation>
2323
<variation name="AddCompareProductsTestVariation3">
24-
<data name="products" xsi:type="string">configurableProduct::configurable_with_qty_1</data>
24+
<data name="products" xsi:type="string">configurableProduct::configurable_as_low_as</data>
2525
<data name="isCustomerLoggedIn" xsi:type="string">Yes</data>
2626
<constraint name="Magento\Catalog\Test\Constraint\AssertProductCompareItemsLink" />
2727
<constraint name="Magento\Catalog\Test\Constraint\AssertProductComparePage" />
2828
<constraint name="Magento\Catalog\Test\Constraint\AssertProductCompareBlockOnCmsPage" />
2929
</variation>
3030
<variation name="AddCompareProductsTestVariation4">
31-
<data name="products" xsi:type="string">catalogProductSimple::simple_for_composite_products,catalogProductVirtual::default,downloadableProduct::default,groupedProduct::grouped_product_with_price,configurableProduct::configurable_with_qty_1,bundleProduct::bundle_dynamic_product,bundleProduct::bundle_fixed_product</data>
31+
<data name="products" xsi:type="string">catalogProductSimple::simple_for_composite_products,catalogProductVirtual::default,downloadableProduct::default,groupedProduct::grouped_product_with_price,configurableProduct::configurable_as_low_as,bundleProduct::bundle_dynamic_product,bundleProduct::bundle_fixed_product</data>
3232
<data name="isCustomerLoggedIn" xsi:type="string">Yes</data>
3333
<constraint name="Magento\Catalog\Test\Constraint\AssertProductCompareItemsLink" />
3434
<constraint name="Magento\Catalog\Test\Constraint\AssertProductComparePage" />

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedProductPage.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\Mtf\Constraint\AbstractConstraint;
1212
use Magento\Catalog\Test\Page\Product\CatalogProductView;
1313
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
14+
use Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep;
15+
use Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep;
1416

1517
/**
1618
* Assert that Catalog Price Rule is applied on Product page.
@@ -38,11 +40,11 @@ public function processAssert(
3840
) {
3941
if ($customer !== null) {
4042
$this->objectManager->create(
41-
\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class,
43+
LoginCustomerOnFrontendStep::class,
4244
['customer' => $customer]
4345
)->run();
4446
} else {
45-
$this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run();
47+
$this->objectManager->create(LogoutCustomerOnFrontendStep::class)->run();
4648
}
4749

4850
$cmsIndexPage->open();
@@ -52,7 +54,7 @@ public function processAssert(
5254
$catalogCategoryViewPage->getListProductBlock()->getProductItem($product)->open();
5355

5456
$catalogProductViewPage->getViewBlock()->waitLoader();
55-
$productPriceBlock = $catalogProductViewPage->getViewBlock()->getPriceBlock();
57+
$productPriceBlock = $catalogProductViewPage->getViewBlock()->getPriceBlock($product);
5658
$actualPrice['special'] = $productPriceBlock->getSpecialPrice();
5759
if ($productPrice[$key]['regular'] !== 'No') {
5860
$actualPrice['regular'] = $productPriceBlock->getOldPrice();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Test\Block\Product;
9+
10+
use Magento\Mtf\Client\Element\SimpleElement;
11+
12+
/**
13+
* This class is used to access the price related information of a configurable product from the storefront.
14+
*/
15+
class Price extends \Magento\Catalog\Test\Block\Product\Price
16+
{
17+
/**
18+
* A CSS selector for a Price label.
19+
*
20+
* @var string
21+
*/
22+
private $priceLabel = '.normal-price .price-label';
23+
24+
/**
25+
* Mapping for different types of Price.
26+
*
27+
* @var array
28+
*/
29+
protected $mapTypePrices = [
30+
'special_price' => [
31+
'selector' => '.normal-price .price',
32+
],
33+
];
34+
35+
/**
36+
* This method returns the price label represented by the block.
37+
*
38+
* @return SimpleElement
39+
*/
40+
public function getPriceLabel()
41+
{
42+
return $this->_rootElement->find($this->priceLabel);
43+
}
44+
}

0 commit comments

Comments
 (0)