Skip to content

Commit b4fb612

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 498775d + 67fe58f commit b4fb612

File tree

33 files changed

+531
-560
lines changed

33 files changed

+531
-560
lines changed

app/code/Magento/Analytics/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<label>Advanced Reporting</label>
1616
<comment><![CDATA[This service provides a dynamic suite of reports with rich insights about your business.
1717
Your reports can be accessed securely on a personalized dashboard outside of the admin panel by clicking on the
18-
"Go to Advanced Reporting" link. </br> For more information, see our <a href="https://magento.com/legal/terms/cloud-terms">
18+
"Go to Advanced Reporting" link. </br> For more information, see our <a target="_blank" href="https://magento.com/legal/terms/cloud-terms">
1919
terms and conditions</a>.]]></comment>
2020
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
2121
<label>Advanced Reporting Service</label>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="AdminThreeDSecurePage" url="admin/system_config/edit/section/three_d_secure/" area="admin" module="Magento_CardinalCommerce">
12+
<section name="AdminCardinalCommerceSection"/>
13+
</page>
14+
</pages>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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="AdminCardinalCommerceSection">
12+
<element name="head" type="button" selector="#three_d_secure_cardinal_config-link"/>
13+
<element name="enabled" type="input" selector="#three_d_secure_cardinal_config_enabled_authorize"/>
14+
<element name="environment" type="input" selector="#three_d_secure_cardinal_config_environment"/>
15+
</section>
16+
</sections>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCardinalCommerceSettingsHiddenTest">
11+
<annotations>
12+
<features value="CardinalCommerce"/>
13+
<title value="CardinalCommerce settings hidden" />
14+
<description value="CardinalCommerce config shouldn't be visible if the 3D secure is disabled for Authorize.Net."/>
15+
<severity value="MINOR"/>
16+
</annotations>
17+
<before>
18+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
19+
<magentoCLI command="config:set three_d_secure/cardinal/enabled_authorizenet 1" stepKey="enableCardinalCommerce"/>
20+
</before>
21+
22+
<after>
23+
<actionGroup ref="logout" stepKey="logout"/>
24+
<magentoCLI command="config:set three_d_secure/cardinal/enabled_authorizenet 0" stepKey="disableCardinalCommerce"/>
25+
</after>
26+
27+
<amOnPage url="{{AdminThreeDSecurePage.url}}" stepKey="openCurrencyOptionsPage" />
28+
<conditionalClick dependentSelector="{{AdminCardinalCommerceSection.enabled}}" visible="false" selector="{{AdminCardinalCommerceSection.head}}" stepKey="openCollapsibleBlock"/>
29+
<see selector="{{AdminCardinalCommerceSection.environment}}" userInput="Production" stepKey="seeEnvironmentProduction"/>
30+
<selectOption selector="{{AdminCardinalCommerceSection.enabled}}" userInput="0" stepKey="disableCardinalCommerceOption"/>
31+
<dontSeeElement selector="{{AdminCardinalCommerceSection.environment}}" stepKey="dontSeeEnvironmentProduction"/>
32+
</test>
33+
</tests>

app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
?>
1818
<?php
19-
$start = microtime(true);
2019
$_productCollection = $block->getLoadedProductCollection();
2120
$_helper = $this->helper(Magento\Catalog\Helper\Output::class);
2221
?>
@@ -98,4 +97,3 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
9897
</div>
9998
<?= $block->getToolbarHtml() ?>
10099
<?php endif; ?>
101-
<?= $time_taken = microtime(true) - $start ?>

app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ private function prepareMeta()
255255
'actionName' => 'toggleModal',
256256
],
257257
],
258+
'imports' => [
259+
'childError' => 'product_form.product_form.advanced_inventory_modal.stock_data:error',
260+
],
258261
'title' => __('Advanced Inventory'),
259262
'provider' => false,
260263
'additionalForGroup' => true,

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

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,22 @@ public function __construct(
242242
*/
243243
public function reindexById($id)
244244
{
245-
$this->reindexByIds([$id]);
245+
try {
246+
$this->cleanProductIndex([$id]);
247+
248+
$products = $this->productLoader->getProducts([$id]);
249+
$activeRules = $this->getActiveRules();
250+
foreach ($products as $product) {
251+
$this->applyRules($activeRules, $product);
252+
}
253+
254+
$this->reindexRuleGroupWebsite->execute();
255+
} catch (\Exception $e) {
256+
$this->critical($e);
257+
throw new \Magento\Framework\Exception\LocalizedException(
258+
__('Catalog rule indexing failed. See details in exception log.')
259+
);
260+
}
246261
}
247262

248263
/**
@@ -275,11 +290,18 @@ protected function doReindexByIds($ids)
275290
{
276291
$this->cleanProductIndex($ids);
277292

278-
$products = $this->productLoader->getProducts($ids);
279-
$activeRules = $this->getActiveRules();
280-
foreach ($products as $product) {
281-
$this->applyRules($activeRules, $product);
293+
/** @var Rule[] $activeRules */
294+
$activeRules = $this->getActiveRules()->getItems();
295+
foreach ($activeRules as $rule) {
296+
$rule->setProductsFilter($ids);
297+
$this->reindexRuleProduct->execute($rule, $this->batchCount);
282298
}
299+
300+
foreach ($ids as $productId) {
301+
$this->cleanProductPriceIndex([$productId]);
302+
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
303+
}
304+
283305
$this->reindexRuleGroupWebsite->execute();
284306
}
285307

@@ -365,17 +387,13 @@ protected function cleanByIds($productIds)
365387
* Assign product to rule
366388
*
367389
* @param Rule $rule
368-
* @param Product $product
390+
* @param int $productEntityId
391+
* @param array $websiteIds
369392
* @return void
370393
*/
371-
private function assignProductToRule(Rule $rule, Product $product): void
394+
private function assignProductToRule(Rule $rule, int $productEntityId, array $websiteIds): void
372395
{
373-
if (!$rule->validate($product)) {
374-
return;
375-
}
376-
377396
$ruleId = (int) $rule->getId();
378-
$productEntityId = (int) $product->getId();
379397
$ruleProductTable = $this->getTable('catalogrule_product');
380398
$this->connection->delete(
381399
$ruleProductTable,
@@ -385,7 +403,6 @@ private function assignProductToRule(Rule $rule, Product $product): void
385403
]
386404
);
387405

388-
$websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
389406
$customerGroupIds = $rule->getCustomerGroupIds();
390407
$fromTime = strtotime($rule->getFromDate());
391408
$toTime = strtotime($rule->getToDate());
@@ -429,12 +446,17 @@ private function assignProductToRule(Rule $rule, Product $product): void
429446
* @param Product $product
430447
* @return $this
431448
* @throws \Exception
449+
* @deprecated
450+
* @see ReindexRuleProduct::execute
432451
* @SuppressWarnings(PHPMD.NPathComplexity)
433452
*/
434453
protected function applyRule(Rule $rule, $product)
435454
{
436-
$this->assignProductToRule($rule, $product);
437-
$this->reindexRuleProductPrice->execute($this->batchCount, $product);
455+
if ($rule->validate($product)) {
456+
$websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
457+
$this->assignProductToRule($rule, $product->getId(), $websiteIds);
458+
}
459+
$this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
438460
$this->reindexRuleGroupWebsite->execute();
439461

440462
return $this;
@@ -450,11 +472,16 @@ protected function applyRule(Rule $rule, $product)
450472
private function applyRules(RuleCollection $ruleCollection, Product $product): void
451473
{
452474
foreach ($ruleCollection as $rule) {
453-
$this->assignProductToRule($rule, $product);
475+
if (!$rule->validate($product)) {
476+
continue;
477+
}
478+
479+
$websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
480+
$this->assignProductToRule($rule, $product->getId(), $websiteIds);
454481
}
455482

456483
$this->cleanProductPriceIndex([$product->getId()]);
457-
$this->reindexRuleProductPrice->execute($this->batchCount, $product);
484+
$this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
458485
}
459486

460487
/**
@@ -507,7 +534,7 @@ protected function updateRuleProductData(Rule $rule)
507534
*/
508535
protected function applyAllRules(Product $product = null)
509536
{
510-
$this->reindexRuleProductPrice->execute($this->batchCount, $product);
537+
$this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
511538
$this->reindexRuleGroupWebsite->execute();
512539
return $this;
513540
}
@@ -562,7 +589,7 @@ protected function calcRuleProductPrice($ruleData, $productData = null)
562589
*/
563590
protected function getRuleProductsStmt($websiteId, Product $product = null)
564591
{
565-
return $this->ruleProductsSelectBuilder->build($websiteId, $product);
592+
return $this->ruleProductsSelectBuilder->build((int) $websiteId, (int) $product->getId());
566593
}
567594

568595
/**

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\CatalogRule\Model\Indexer;
88

9-
use Magento\Catalog\Model\Product;
109
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1110
use Magento\Store\Model\StoreManagerInterface;
1211

@@ -65,19 +64,19 @@ public function __construct(
6564
* Reindex product prices.
6665
*
6766
* @param int $batchCount
68-
* @param Product|null $product
67+
* @param int|null $productId
6968
* @param bool $useAdditionalTable
7069
* @return bool
7170
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
7271
*/
73-
public function execute($batchCount, Product $product = null, $useAdditionalTable = false)
72+
public function execute(int $batchCount, ?int $productId = null, bool $useAdditionalTable = false)
7473
{
7574
/**
7675
* Update products rules prices per each website separately
7776
* because for each website date in website's timezone should be used
7877
*/
7978
foreach ($this->storeManager->getWebsites() as $website) {
80-
$productsStmt = $this->ruleProductsSelectBuilder->build($website->getId(), $product, $useAdditionalTable);
79+
$productsStmt = $this->ruleProductsSelectBuilder->build($website->getId(), $productId, $useAdditionalTable);
8180
$dayPrices = [];
8281
$stopFlags = [];
8382
$prevKey = null;

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,12 @@ public function __construct(
7474
* Build select for indexer according passed parameters.
7575
*
7676
* @param int $websiteId
77-
* @param \Magento\Catalog\Model\Product|null $product
77+
* @param int|null $productId
7878
* @param bool $useAdditionalTable
7979
* @return \Zend_Db_Statement_Interface
8080
*/
81-
public function build(
82-
$websiteId,
83-
\Magento\Catalog\Model\Product $product = null,
84-
$useAdditionalTable = false
85-
) {
81+
public function build(int $websiteId, ?int $productId = null, bool $useAdditionalTable = false)
82+
{
8683
$connection = $this->resource->getConnection();
8784
$indexTable = $this->resource->getTableName('catalogrule_product');
8885
if ($useAdditionalTable) {
@@ -107,8 +104,8 @@ public function build(
107104
['rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id']
108105
);
109106

110-
if ($product && $product->getEntityId()) {
111-
$select->where('rp.product_id=?', $product->getEntityId());
107+
if ($productId) {
108+
$select->where('rp.product_id=?', $productId);
112109
}
113110

114111
/**
@@ -159,9 +156,11 @@ public function build(
159156
sprintf($joinCondition, $tableAlias, $storeId),
160157
[]
161158
);
162-
$select->columns([
163-
'default_price' => $connection->getIfNullSql($tableAlias . '.value', 'pp_default.value'),
164-
]);
159+
$select->columns(
160+
[
161+
'default_price' => $connection->getIfNullSql($tableAlias . '.value', 'pp_default.value'),
162+
]
163+
);
165164

166165
return $connection->query($select);
167166
}

0 commit comments

Comments
 (0)