Skip to content

Commit 15eadfc

Browse files
merge magento/2.2.10-develop into magento-trigger/MC-18491
2 parents a8d44c3 + d6b2741 commit 15eadfc

File tree

34 files changed

+776
-308
lines changed

34 files changed

+776
-308
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminClickSaveAndContinueButtonActionGroup">
12+
<annotations>
13+
<description>Click "Save and Continue" button and assert message</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="message" type="string"/>
17+
</arguments>
18+
<scrollToTopOfPage stepKey="scrollToPageTop"/>
19+
<click selector="{{AdminMainActionsSection.saveAndContinue}}" stepKey="clickSaveAndContinue"/>
20+
<waitForElementVisible time="30" selector="{{AdminMessagesSection.success}}" stepKey="waitMessage"/>
21+
<see selector="{{AdminMessagesSection.success}}" userInput="{{message}}" stepKey="verifyMessage"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ define(
246246
return;
247247
}
248248

249-
self.setPaymentPayload(payload);
250-
self.placeOrder();
249+
if (self.validateCardType()) {
250+
self.setPaymentPayload(payload);
251+
self.placeOrder();
252+
}
251253
});
252254
}
253255
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
</arguments>
6262
<!-- Go to storefront category page -->
6363
<amOnPage url="{{StorefrontCategoryPage.url(category)}}?product_list_mode={{mode}}&amp;product_list_order={{sortBy}}&amp;product_list_dir={{sort}}" stepKey="onCategoryPage"/>
64+
<waitForPageLoad time="30" stepKey="waitCategoryPageLoaded"/>
6465
</actionGroup>
6566

6667
<actionGroup name="VerifyCategoryPageParameters">
@@ -70,7 +71,6 @@
7071
<argument name="numOfProductsPerPage" type="string"/>
7172
<argument name="sortBy" type="string" defaultValue="position"/>
7273
</arguments>
73-
<amOnPage url="{{StorefrontCategoryPage.url(categoryName)}}" stepKey="navigateToCategoryPage"/>
7474
<seeInTitle userInput="{{categoryName}}" stepKey="assertCategoryNameInTitle"/>
7575
<see userInput="{{categoryName}}" selector="{{StorefrontCategoryMainSection.categoryTitle}}" stepKey="assertCategoryName"/>
7676
<see userInput="{{mode}}" selector="{{StorefrontCategoryPagerSection.modeGridIsActive}}" stepKey="assertViewMode"/>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
9+
<actionGroup name="StorefrontNavigateCategoryPageActionGroup">
10+
<annotations>
11+
<description>Navigates storefront category page by url key</description>
12+
</annotations>
13+
<arguments>
14+
<argument name="categoryUrlKey"/>
15+
</arguments>
16+
<amOnPage url="{{StorefrontCategoryPage.url(categoryUrlKey)}}" stepKey="navigateStorefrontCategoryPage"/>
17+
<waitForPageLoad time="30" stepKey="waitCategoryPageLoaded"/>
18+
</actionGroup>
19+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontRememberCategoryPaginationTest.xml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
</createData>
3131

3232
<createData entity="RememberPaginationCatalogStorefrontConfig" stepKey="setRememberPaginationCatalogStorefrontConfig"/>
33-
<magentoCLI command="cache:flush" stepKey="clearCache"/>
3433
</before>
3534

3635
<after>
@@ -40,26 +39,29 @@
4039
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
4140
<deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/>
4241
<deleteData createDataKey="createCategory1" stepKey="deleteCategory1"/>
43-
44-
<magentoCLI command="cache:flush" stepKey="flushCache"/>
4542
</after>
4643

47-
<actionGroup ref="GoToStorefrontCategoryPageByParameters" stepKey="goToStorefrontCategory1Page">
48-
<argument name="category" value="$$createCategory.name$$"/>
44+
<actionGroup ref="GoToStorefrontCategoryPageByParameters" stepKey="goToStorefrontCategoryPage">
45+
<argument name="category" value="$$createCategory.custom_attributes[url_key]$$"/>
4946
<argument name="mode" value="grid"/>
5047
</actionGroup>
5148

5249
<selectOption selector="{{StorefrontCategoryPagerSection.perPage}}" userInput="12" stepKey="setPerPage" />
53-
<waitForPageLoad stepKey="waitForPageLoad"/>
50+
<waitForPageLoad time="30" stepKey="waitForPageLoad"/>
51+
52+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage">
53+
<argument name="categoryUrlKey" value="$$createCategory.custom_attributes[url_key]$$"/>
54+
</actionGroup>
5455

5556
<actionGroup ref="VerifyCategoryPageParameters" stepKey="verifyCategoryPageParameters">
5657
<argument name="categoryName" value="$$createCategory.name$$"/>
5758
<argument name="mode" value="grid"/>
5859
<argument name="numOfProductsPerPage" value="12"/>
5960
</actionGroup>
6061

61-
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory1.name$$)}}" stepKey="navigateToCategory1Page"/>
62-
<waitForPageLoad stepKey="waitForCategory1PageToLoad"/>
62+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategory1Page">
63+
<argument name="categoryUrlKey" value="$$createCategory1.custom_attributes[url_key]$$"/>
64+
</actionGroup>
6365

6466
<actionGroup ref="VerifyCategoryPageParameters" stepKey="verifyCategory1PageParameters">
6567
<argument name="categoryName" value="$$createCategory1.name$$"/>

app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88

99
use Magento\CatalogRule\Model\Indexer\IndexerTableSwapperInterface as TableSwapper;
1010
use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;
11-
use Magento\Framework\App\ObjectManager;
11+
use Magento\CatalogRule\Model\Rule;
12+
use Magento\Framework\App\ResourceConnection;
13+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
14+
use Magento\Store\Model\ScopeInterface;
1215

1316
/**
1417
* Reindex rule relations with products.
1518
*/
1619
class ReindexRuleProduct
1720
{
1821
/**
19-
* @var \Magento\Framework\App\ResourceConnection
22+
* @var ResourceConnection
2023
*/
2124
private $resource;
2225

@@ -26,37 +29,41 @@ class ReindexRuleProduct
2629
private $tableSwapper;
2730

2831
/**
29-
* @param \Magento\Framework\App\ResourceConnection $resource
32+
* @var TimezoneInterface
33+
*/
34+
private $localeDate;
35+
36+
/**
37+
* @param ResourceConnection $resource
3038
* @param ActiveTableSwitcher $activeTableSwitcher
31-
* @param TableSwapper|null $tableSwapper
39+
* @param TableSwapper $tableSwapper
40+
* @param TimezoneInterface $localeDate
3241
*
3342
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3443
*/
3544
public function __construct(
36-
\Magento\Framework\App\ResourceConnection $resource,
45+
ResourceConnection $resource,
3746
ActiveTableSwitcher $activeTableSwitcher,
38-
TableSwapper $tableSwapper = null
47+
TableSwapper $tableSwapper,
48+
TimezoneInterface $localeDate
3949
) {
4050
$this->resource = $resource;
41-
$this->tableSwapper = $tableSwapper ??
42-
ObjectManager::getInstance()->get(TableSwapper::class);
51+
$this->tableSwapper = $tableSwapper;
52+
$this->localeDate = $localeDate;
4353
}
4454

4555
/**
4656
* Reindex information about rule relations with products.
4757
*
48-
* @param \Magento\CatalogRule\Model\Rule $rule
58+
* @param Rule $rule
4959
* @param int $batchCount
5060
* @param bool $useAdditionalTable
5161
* @return bool
5262
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5363
* @SuppressWarnings(PHPMD.NPathComplexity)
5464
*/
55-
public function execute(
56-
\Magento\CatalogRule\Model\Rule $rule,
57-
$batchCount,
58-
$useAdditionalTable = false
59-
) {
65+
public function execute(Rule $rule, $batchCount, $useAdditionalTable = false)
66+
{
6067
if (!$rule->getIsActive() || empty($rule->getWebsiteIds())) {
6168
return false;
6269
}
@@ -80,21 +87,26 @@ public function execute(
8087

8188
$ruleId = $rule->getId();
8289
$customerGroupIds = $rule->getCustomerGroupIds();
83-
$fromTime = strtotime($rule->getFromDate());
84-
$toTime = strtotime($rule->getToDate());
85-
$toTime = $toTime ? $toTime + \Magento\CatalogRule\Model\Indexer\IndexBuilder::SECONDS_IN_DAY - 1 : 0;
8690
$sortOrder = (int)$rule->getSortOrder();
8791
$actionOperator = $rule->getSimpleAction();
8892
$actionAmount = $rule->getDiscountAmount();
8993
$actionStop = $rule->getStopRulesProcessing();
9094

9195
$rows = [];
96+
foreach ($websiteIds as $websiteId) {
97+
$scopeTz = new \DateTimeZone(
98+
$this->localeDate->getConfigTimezone(ScopeInterface::SCOPE_WEBSITE, $websiteId)
99+
);
100+
$fromTime = (new \DateTime($rule->getFromDate(), $scopeTz))->getTimestamp();
101+
$toTime = $rule->getToDate()
102+
? (new \DateTime($rule->getToDate(), $scopeTz))->getTimestamp() + IndexBuilder::SECONDS_IN_DAY - 1
103+
: 0;
92104

93-
foreach ($productIds as $productId => $validationByWebsite) {
94-
foreach ($websiteIds as $websiteId) {
105+
foreach ($productIds as $productId => $validationByWebsite) {
95106
if (empty($validationByWebsite[$websiteId])) {
96107
continue;
97108
}
109+
98110
foreach ($customerGroupIds as $customerGroupId) {
99111
$rows[] = [
100112
'rule_id' => $ruleId,
@@ -119,6 +131,7 @@ public function execute(
119131
if (!empty($rows)) {
120132
$connection->insertMultiple($indexTable, $rows);
121133
}
134+
122135
return true;
123136
}
124137
}

app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProductPrice.php

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,89 @@
66

77
namespace Magento\CatalogRule\Model\Indexer;
88

9+
use Magento\Catalog\Model\Product;
10+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
11+
use Magento\Store\Model\StoreManagerInterface;
12+
913
/**
1014
* Reindex product prices according rule settings.
1115
*/
1216
class ReindexRuleProductPrice
1317
{
1418
/**
15-
* @var \Magento\Store\Model\StoreManagerInterface
19+
* @var StoreManagerInterface
1620
*/
1721
private $storeManager;
1822

1923
/**
20-
* @var \Magento\CatalogRule\Model\Indexer\RuleProductsSelectBuilder
24+
* @var RuleProductsSelectBuilder
2125
*/
2226
private $ruleProductsSelectBuilder;
2327

2428
/**
25-
* @var \Magento\CatalogRule\Model\Indexer\ProductPriceCalculator
29+
* @var ProductPriceCalculator
2630
*/
2731
private $productPriceCalculator;
2832

2933
/**
30-
* @var \Magento\Framework\Stdlib\DateTime\DateTime
34+
* @var TimezoneInterface
3135
*/
32-
private $dateTime;
36+
private $localeDate;
3337

3438
/**
35-
* @var \Magento\CatalogRule\Model\Indexer\RuleProductPricesPersistor
39+
* @var RuleProductPricesPersistor
3640
*/
3741
private $pricesPersistor;
3842

3943
/**
40-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
44+
* @param StoreManagerInterface $storeManager
4145
* @param RuleProductsSelectBuilder $ruleProductsSelectBuilder
4246
* @param ProductPriceCalculator $productPriceCalculator
43-
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
44-
* @param \Magento\CatalogRule\Model\Indexer\RuleProductPricesPersistor $pricesPersistor
47+
* @param TimezoneInterface $localeDate
48+
* @param RuleProductPricesPersistor $pricesPersistor
4549
*/
4650
public function __construct(
47-
\Magento\Store\Model\StoreManagerInterface $storeManager,
48-
\Magento\CatalogRule\Model\Indexer\RuleProductsSelectBuilder $ruleProductsSelectBuilder,
49-
\Magento\CatalogRule\Model\Indexer\ProductPriceCalculator $productPriceCalculator,
50-
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
51-
\Magento\CatalogRule\Model\Indexer\RuleProductPricesPersistor $pricesPersistor
51+
StoreManagerInterface $storeManager,
52+
RuleProductsSelectBuilder $ruleProductsSelectBuilder,
53+
ProductPriceCalculator $productPriceCalculator,
54+
TimezoneInterface $localeDate,
55+
RuleProductPricesPersistor $pricesPersistor
5256
) {
5357
$this->storeManager = $storeManager;
5458
$this->ruleProductsSelectBuilder = $ruleProductsSelectBuilder;
5559
$this->productPriceCalculator = $productPriceCalculator;
56-
$this->dateTime = $dateTime;
60+
$this->localeDate = $localeDate;
5761
$this->pricesPersistor = $pricesPersistor;
5862
}
5963

6064
/**
6165
* Reindex product prices.
6266
*
6367
* @param int $batchCount
64-
* @param \Magento\Catalog\Model\Product|null $product
68+
* @param Product|null $product
6569
* @param bool $useAdditionalTable
6670
* @return bool
6771
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6872
*/
69-
public function execute(
70-
$batchCount,
71-
\Magento\Catalog\Model\Product $product = null,
72-
$useAdditionalTable = false
73-
) {
74-
$fromDate = mktime(0, 0, 0, date('m'), date('d') - 1);
75-
$toDate = mktime(0, 0, 0, date('m'), date('d') + 1);
76-
73+
public function execute($batchCount, Product $product = null, $useAdditionalTable = false)
74+
{
7775
/**
7876
* Update products rules prices per each website separately
79-
* because of max join limit in mysql
77+
* because for each website date in website's timezone should be used
8078
*/
8179
foreach ($this->storeManager->getWebsites() as $website) {
8280
$productsStmt = $this->ruleProductsSelectBuilder->build($website->getId(), $product, $useAdditionalTable);
8381
$dayPrices = [];
8482
$stopFlags = [];
8583
$prevKey = null;
8684

85+
$storeGroup = $this->storeManager->getGroup($website->getDefaultGroupId());
86+
$currentDate = $this->localeDate->scopeDate($storeGroup->getDefaultStoreId(), null, true);
87+
$previousDate = (clone $currentDate)->modify('-1 day');
88+
$previousDate->setTime(23, 59, 59);
89+
$nextDate = (clone $currentDate)->modify('+1 day');
90+
$nextDate->setTime(0, 0, 0);
91+
8792
while ($ruleData = $productsStmt->fetch()) {
8893
$ruleProductId = $ruleData['product_id'];
8994
$productKey = $ruleProductId .
@@ -100,12 +105,11 @@ public function execute(
100105
}
101106
}
102107

103-
$ruleData['from_time'] = $this->roundTime($ruleData['from_time']);
104-
$ruleData['to_time'] = $this->roundTime($ruleData['to_time']);
105108
/**
106109
* Build prices for each day
107110
*/
108-
for ($time = $fromDate; $time <= $toDate; $time += IndexBuilder::SECONDS_IN_DAY) {
111+
foreach ([$previousDate, $currentDate, $nextDate] as $date) {
112+
$time = $date->getTimestamp();
109113
if (($ruleData['from_time'] == 0 ||
110114
$time >= $ruleData['from_time']) && ($ruleData['to_time'] == 0 ||
111115
$time <= $ruleData['to_time'])
@@ -118,7 +122,7 @@ public function execute(
118122

119123
if (!isset($dayPrices[$priceKey])) {
120124
$dayPrices[$priceKey] = [
121-
'rule_date' => $time,
125+
'rule_date' => $date,
122126
'website_id' => $ruleData['website_id'],
123127
'customer_group_id' => $ruleData['customer_group_id'],
124128
'product_id' => $ruleProductId,
@@ -151,18 +155,7 @@ public function execute(
151155
}
152156
$this->pricesPersistor->execute($dayPrices, $useAdditionalTable);
153157
}
154-
return true;
155-
}
156158

157-
/**
158-
* @param int $timeStamp
159-
* @return int
160-
*/
161-
private function roundTime($timeStamp)
162-
{
163-
if (is_numeric($timeStamp) && $timeStamp != 0) {
164-
$timeStamp = $this->dateTime->timestamp($this->dateTime->date('Y-m-d 00:00:00', $timeStamp));
165-
}
166-
return $timeStamp;
159+
return true;
167160
}
168161
}

0 commit comments

Comments
 (0)