Skip to content

Commit 76fcd12

Browse files
authored
Merge pull request #3712 from magento-tsg/2.2-develop-pr75
[TSG] Backporting for 2.2 (pr75) (2.2)
2 parents e592fca + ad10c87 commit 76fcd12

File tree

41 files changed

+1459
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1459
-157
lines changed

app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationGeneralSectionPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<pages xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
88
<page name="AdminConfigurationGeneralSectionPage" url="admin/system_config/edit/section/general/{{group_anchor}}" parameterized="true" area="admin" module="Magento_Config">
99
<section name="AdminConfigurationGeneralSectionCountryOptionsGroupSection"/>
10+
<section name="LocaleOptionsSection"/>
1011
</page>
1112
</pages>

app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
1111
<page name="ConfigurationStoresPage" url="admin/system_config/edit/section/cms/" area="admin" module="Catalog">
1212
<section name="WYSIWYGOptionsSection"/>
1313
</page>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="LocaleOptionsSection">
12+
<element name="timezone" type="select" selector="#general_locale_timezone"/>
13+
<element name="useDefault" type="checkbox" selector="#general_locale_timezone_inherit"/>
14+
</section>
15+
</sections>

app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Bundle\Test\Unit\Pricing\Price;
77

88
use \Magento\Bundle\Pricing\Price\SpecialPrice;
9+
use Magento\Store\Api\Data\WebsiteInterface;
910

1011
class SpecialPriceTest extends \PHPUnit\Framework\TestCase
1112
{
@@ -77,12 +78,6 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva
7778
->method('getSpecialPrice')
7879
->will($this->returnValue($specialPrice));
7980

80-
$store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
81-
->disableOriginalConstructor()
82-
->getMock();
83-
$this->saleable->expects($this->once())
84-
->method('getStore')
85-
->will($this->returnValue($store));
8681
$this->saleable->expects($this->once())
8782
->method('getSpecialFromDate')
8883
->will($this->returnValue($specialFromDate));
@@ -92,7 +87,7 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva
9287

9388
$this->localeDate->expects($this->once())
9489
->method('isScopeDateInInterval')
95-
->with($store, $specialFromDate, $specialToDate)
90+
->with(WebsiteInterface::ADMIN_CODE, $specialFromDate, $specialToDate)
9691
->will($this->returnValue($isScopeDateInInterval));
9792

9893
$this->priceCurrencyMock->expects($this->never())

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\UrlInterface;
1515
use Magento\Ui\Component\Container;
1616
use Magento\Ui\Component\Form;
17+
use Magento\Ui\Component\Form\Fieldset;
1718
use Magento\Ui\Component\Modal;
1819

1920
/**
@@ -69,13 +70,26 @@ public function __construct(
6970
}
7071

7172
/**
72-
* {@inheritdoc}
73+
* @inheritdoc
74+
*
7375
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
7476
*/
7577
public function modifyMeta(array $meta)
7678
{
7779
$meta = $this->removeFixedTierPrice($meta);
78-
$path = $this->arrayManager->findPath(static::CODE_BUNDLE_DATA, $meta, null, 'children');
80+
81+
$groupCode = static::CODE_BUNDLE_DATA;
82+
$path = $this->arrayManager->findPath($groupCode, $meta, null, 'children');
83+
if (empty($path)) {
84+
$meta[$groupCode]['children'] = [];
85+
$meta[$groupCode]['arguments']['data']['config'] = [
86+
'componentType' => Fieldset::NAME,
87+
'label' => __('Bundle Items'),
88+
'collapsible' => true,
89+
];
90+
91+
$path = $this->arrayManager->findPath($groupCode, $meta, null, 'children');
92+
}
7993

8094
$meta = $this->arrayManager->merge(
8195
$path,
@@ -220,7 +234,7 @@ private function removeFixedTierPrice(array $meta)
220234
}
221235

222236
/**
223-
* {@inheritdoc}
237+
* @inheritdoc
224238
*/
225239
public function modifyData(array $data)
226240
{

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Store\Model\Store;
1212
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
1313
use Magento\Framework\App\ObjectManager;
14+
use Magento\Store\Api\Data\WebsiteInterface;
1415

1516
/**
1617
* Product type price model
@@ -184,6 +185,8 @@ public function getFinalPrice($qty, $product)
184185
}
185186

186187
/**
188+
* Retrieve final price for child product.
189+
*
187190
* @param Product $product
188191
* @param float $productQty
189192
* @param Product $childProduct
@@ -428,6 +431,8 @@ public function setTierPrices($product, array $tierPrices = null)
428431
}
429432

430433
/**
434+
* Retrieve customer group id from product.
435+
*
431436
* @param Product $product
432437
* @return int
433438
*/
@@ -453,7 +458,7 @@ protected function _applySpecialPrice($product, $finalPrice)
453458
$product->getSpecialPrice(),
454459
$product->getSpecialFromDate(),
455460
$product->getSpecialToDate(),
456-
$product->getStore()
461+
WebsiteInterface::ADMIN_CODE
457462
);
458463
}
459464

@@ -601,7 +606,7 @@ public function calculatePrice(
601606
$specialPrice,
602607
$specialPriceFrom,
603608
$specialPriceTo,
604-
$sId
609+
WebsiteInterface::ADMIN_CODE
605610
);
606611

607612
if ($rulePrice === false) {

app/code/Magento/Catalog/Pricing/Price/SpecialPrice.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Pricing\Price\AbstractPrice;
1212
use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
1313
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
14+
use Magento\Store\Api\Data\WebsiteInterface;
1415

1516
/**
1617
* Special price model
@@ -46,6 +47,8 @@ public function __construct(
4647
}
4748

4849
/**
50+
* Retrieve special price.
51+
*
4952
* @return bool|float
5053
*/
5154
public function getValue()
@@ -96,19 +99,19 @@ public function getSpecialToDate()
9699
}
97100

98101
/**
99-
* @return bool
102+
* @inheritdoc
100103
*/
101104
public function isScopeDateInInterval()
102105
{
103106
return $this->localeDate->isScopeDateInInterval(
104-
$this->product->getStore(),
107+
WebsiteInterface::ADMIN_CODE,
105108
$this->getSpecialFromDate(),
106109
$this->getSpecialToDate()
107110
);
108111
}
109112

110113
/**
111-
* @return bool
114+
* @inheritdoc
112115
*/
113116
public function isPercentageDiscount()
114117
{

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductToggle"/>
1717
<waitForElementVisible selector="{{AdminProductGridActionSection.addTypeProduct(product.type_id)}}" stepKey="waitForAddProductDropdown" time="30"/>
1818
<click selector="{{AdminProductGridActionSection.addTypeProduct(product.type_id)}}" stepKey="clickAddProductType"/>
19-
<waitForPageLoad stepKey="waitForCreateProductPageLoad"/>
19+
<waitForPageLoad time="30" stepKey="waitForCreateProductPageLoad"/>
2020
<seeInCurrentUrl url="{{AdminProductCreatePage.url(AddToDefaultSet.attributeSetId, product.type_id)}}" stepKey="seeNewProductUrl"/>
2121
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Product" stepKey="seeNewProductTitle"/>
2222
</actionGroup>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<element name="productSku" type="text" selector=".product.attribute.sku>.value"/>
1515
<element name="productPrice" type="text" selector=".price"/>
1616
<element name="specialPrice" type="text" selector=".special-price"/>
17+
<element name="specialPriceValue" type="text" selector=".special-price .price"/>
1718
<element name="qty" type="input" selector="#qty"/>
1819
<element name="productStockStatus" type="text" selector=".stock[title=Availability]>span"/>
1920
<element name="productDescription" type="text" selector="#description .value"/>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontSpecialPriceForDifferentTimezonesForWebsitesTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Check that special price displayed when 'default config' scope timezone does not match 'website' scope timezone"/>
15+
<description value="Check that special price displayed when 'default config' scope timezone does not match 'website' scope timezone"/>
16+
<stories value="Verify product special price"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-13788"/>
19+
<useCaseId value="MAGETWO-95452"/>
20+
<group value="Catalog"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
24+
<createData entity="SimpleProduct3" stepKey="createProduct"/>
25+
26+
<!--Create customer-->
27+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
28+
29+
<!--Set timezone for default config-->
30+
<amOnPage url="{{AdminConfigurationGeneralSectionPage.url('#general_locale-link')}}" stepKey="openLocaleSection"/>
31+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="Central European Standard Time (Europe/Paris)" stepKey="setTimezone"/>
32+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig"/>
33+
<!--Set timezone for Main Website-->
34+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchStoreViewActionGroup">
35+
<argument name="scopeName" value="_defaultWebsite.name"/>
36+
</actionGroup>
37+
<uncheckOption selector="{{LocaleOptionsSection.useDefault}}" stepKey="uncheckUseDefault"/>
38+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="Greenwich Mean Time (Africa/Abidjan)" stepKey="setTimezone1"/>
39+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig1"/>
40+
</before>
41+
<after>
42+
<!--Delete create data-->
43+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
44+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
45+
46+
<!--Reset timezone-->
47+
<amOnPage url="{{AdminConfigurationGeneralSectionPage.url('#general_locale-link')}}" stepKey="openLocaleSectionReset"/>
48+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="{{_ENV.DEFAULT_TIMEZONE}}" stepKey="resetTimezone"/>
49+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigReset"/>
50+
51+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreViewActionGroup">
52+
<argument name="scopeName" value="_defaultWebsite.name"/>
53+
</actionGroup>
54+
<checkOption selector="{{LocaleOptionsSection.useDefault}}" stepKey="checkUseDefault"/>
55+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigReset1"/>
56+
57+
<actionGroup ref="logout" stepKey="logout"/>
58+
</after>
59+
60+
<!--Set special price to created product-->
61+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="openAdminEditPage"/>
62+
<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="setSpecialPriceToCreatedProduct">
63+
<argument name="price" value="15"/>
64+
</actionGroup>
65+
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
66+
67+
<!--Login to storefront from customer and check price-->
68+
<actionGroup ref="CustomerLoginOnStorefront" stepKey="logInFromCustomer">
69+
<argument name="customer" value="$$createCustomer$$"/>
70+
</actionGroup>
71+
72+
<!--Go to the product page and check special price-->
73+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="amOnSimpleProductPage"/>
74+
<see selector="{{StorefrontProductInfoMainSection.specialPriceValue}}" userInput='$15.00' stepKey="assertSpecialPrice"/>
75+
</test>
76+
</tests>

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public function __construct(
139139
}
140140

141141
/**
142-
* {@inheritdoc}
142+
* @inheritdoc
143+
*
143144
* @since 101.0.0
144145
*/
145146
public function modifyMeta(array $meta)
@@ -158,7 +159,8 @@ public function modifyMeta(array $meta)
158159
}
159160

160161
/**
161-
* {@inheritdoc}
162+
* @inheritdoc
163+
*
162164
* @since 101.0.0
163165
*/
164166
public function modifyData(array $data)
@@ -381,6 +383,7 @@ private function addAdvancedPriceLink()
381383
);
382384

383385
$advancedPricingButton['arguments']['data']['config'] = [
386+
'dataScope' => 'advanced_pricing_button',
384387
'displayAsLink' => true,
385388
'formElement' => Container::NAME,
386389
'componentType' => Container::NAME,

app/code/Magento/ConfigurableProduct/Pricing/Render/TierPriceBox.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\ConfigurableProduct\Pricing\Render;
77

8+
use Magento\Catalog\Pricing\Price\TierPrice;
9+
810
/**
911
* Responsible for displaying tier price box on configurable product page.
1012
*
@@ -17,9 +19,28 @@ class TierPriceBox extends FinalPriceBox
1719
*/
1820
public function toHtml()
1921
{
20-
// Hide tier price block in case of MSRP.
21-
if (!$this->isMsrpPriceApplicable()) {
22+
// Hide tier price block in case of MSRP or in case when no options with tier price.
23+
if (!$this->isMsrpPriceApplicable() && $this->isTierPriceApplicable()) {
2224
return parent::toHtml();
2325
}
2426
}
27+
28+
/**
29+
* Check if at least one of simple products has tier price.
30+
*
31+
* @return bool
32+
*/
33+
private function isTierPriceApplicable(): bool
34+
{
35+
$product = $this->getSaleableItem();
36+
foreach ($product->getTypeInstance()->getUsedProducts($product) as $simpleProduct) {
37+
if ($simpleProduct->isSalable()
38+
&& !empty($simpleProduct->getPriceInfo()->getPrice(TierPrice::PRICE_CODE)->getTierPriceList())
39+
) {
40+
return true;
41+
}
42+
}
43+
44+
return false;
45+
}
2546
}

app/code/Magento/ConfigurableProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="stockIndication" type="block" selector=".stock" />
1515
<element name="productAttributeOptionsSelectButton" type="select" selector="#product-options-wrapper .super-attribute-select"/>
1616
<element name="optionByAttributeId" type="input" selector="#attribute{{var1}}" parameterized="true"/>
17+
<element name="productPriceBox" type="block" selector=".price-box"/>
1718
</section>
1819
</sections>

0 commit comments

Comments
 (0)