Skip to content

Commit 09a66d7

Browse files
authored
Merge pull request #7601 from magento-l3/PR_L3_22_04_2022
PR_L3_22_04_2022
2 parents 96faea7 + e9ba895 commit 09a66d7

File tree

109 files changed

+3058
-928
lines changed

Some content is hidden

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

109 files changed

+3058
-928
lines changed

app/code/Magento/AdvancedPricingImportExport/Controller/Adminhtml/Export/GetFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function execute()
3434
/** @var $export \Magento\ImportExport\Model\Export */
3535
$export = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class);
3636
$export->setData($data);
37-
$export->filterAttributeCollection(
38-
$attrFilterBlock->prepareCollection($export->getEntityAttributeCollection())
37+
$attrFilterBlock->prepareCollection(
38+
$export->filterAttributeCollection($export->getEntityAttributeCollection())
3939
);
4040
return $resultLayout;
4141
} catch (\Exception $e) {

app/code/Magento/AdvancedSearch/view/frontend/templates/search_data.phtml

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

77
/**
88
* @var \Magento\AdvancedSearch\Block\SearchData $block
9+
* @var \Magento\Framework\Locale\LocaleFormatter $localeFormatter
910
*/
1011
?>
1112
<?php
1213
/** @var \Magento\Search\Model\QueryResult[] $data */
1314
$data = $block->getItems();
14-
if (count($data)) : ?>
15+
if (count($data)): ?>
1516
<dl class="block">
1617
<dt class="title"><?= $block->escapeHtml(__($block->getTitle())) ?></dt>
17-
<?php foreach ($data as $additionalInfo) : ?>
18+
<?php foreach ($data as $additionalInfo): ?>
1819
<dd class="item">
1920
<a href="<?= $block->escapeUrl($block->getLink($additionalInfo->getQueryText())) ?>"
2021
><?= $block->escapeHtml($additionalInfo->getQueryText()) ?></a>
21-
<?php if ($block->isShowResultsCount()) : ?>
22-
<span class="count"><?= /* @noEscape */ (int)$additionalInfo->getResultsCount() ?></span>
22+
<?php if ($block->isShowResultsCount()): ?>
23+
<span class="count">
24+
<?= /* @noEscape */ $localeFormatter->formatNumber((int)$additionalInfo->getResultsCount()) ?>
25+
</span>
2326
<?php endif; ?>
2427
</dd>
2528
<?php endforeach; ?>

app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
*/
77
namespace Magento\Backend\Controller\Adminhtml\Ajax;
88

9+
use Magento\Framework\App\Action\HttpPostActionInterface;
910
use Magento\Backend\App\Action;
1011

11-
class Translate extends \Magento\Backend\App\Action
12+
class Translate extends \Magento\Backend\App\Action implements HttpPostActionInterface
1213
{
1314
/**
1415
* @var \Magento\Framework\Translate\Inline\ParserInterface
@@ -23,7 +24,7 @@ class Translate extends \Magento\Backend\App\Action
2324
/**
2425
* Authorization level of a basic admin session
2526
*/
26-
const ADMIN_RESOURCE = 'Magento_Backend::content_translation';
27+
public const ADMIN_RESOURCE = 'Magento_Backend::content_translation';
2728

2829
/**
2930
* @param Action\Context $context
@@ -52,8 +53,7 @@ public function execute()
5253
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
5354
$resultJson = $this->resultJsonFactory->create();
5455
try {
55-
$this->inlineParser->processAjaxPost($translate);
56-
$response = ['success' => 'true'];
56+
$response = $this->inlineParser->processAjaxPost($translate);
5757
} catch (\Exception $e) {
5858
$response = ['error' => 'true', 'message' => $e->getMessage()];
5959
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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\Bundle\Plugin\Framework\Data\Form\Element;
9+
10+
use Magento\Framework\Data\Form\Element\AbstractElement;
11+
use Magento\Framework\Data\Form\Element\Fieldset;
12+
13+
/**
14+
* Plugin that fixes mapping of value and label for bundle dynamic attributes
15+
*/
16+
class FieldsetPlugin
17+
{
18+
/**
19+
* @var string[]
20+
*/
21+
private $dynamicAttributeNames = ['sku_type', 'weight_type', 'price_type'];
22+
23+
/**
24+
* Normalise bundle dynamic attributes values
25+
*
26+
* Normalise attribute values for bundle dynamic attributes generated by form element
27+
* to make it consistent across the system (dynamic => 1, fixed => 0)
28+
*
29+
* @param Fieldset $subject
30+
* @param AbstractElement $result
31+
* @return AbstractElement
32+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
*/
34+
public function afterAddField(Fieldset $subject, AbstractElement $result)
35+
{
36+
if (!in_array($result->getAttributeCode(), $this->dynamicAttributeNames)) {
37+
return $result;
38+
}
39+
40+
$new = [];
41+
foreach ($result->getValues() as $option) {
42+
$option['value'] = (int)!$option['value'];
43+
$new[] = $option;
44+
}
45+
46+
$result->setValues($new);
47+
return $result;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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="AdminAssertBundleDynamicAttributesOnProductEditPageActionGroup">
12+
<annotations>
13+
<description>Verifies bundle dynamic attributes on the Product Edit page in admin.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="dynamicSku" defaultValue="true" type="string"/>
17+
<argument name="dynamicPrice" defaultValue="true" type="string"/>
18+
<argument name="dynamicWeight" defaultValue="true" type="string"/>
19+
</arguments>
20+
<executeJS function="return document.querySelector(&quot;{{AdminProductFormBundleSection.dynamicSkuInput}}&quot;).checked.toString()" stepKey="dynamicSkuCheckedValue"/>
21+
<assertEquals stepKey="assertDynamicSku">
22+
<actualResult type="variable">dynamicSkuCheckedValue</actualResult>
23+
<expectedResult type="string">{{dynamicSku}}</expectedResult>
24+
</assertEquals>
25+
<executeJS function="return document.querySelector(&quot;{{AdminProductFormBundleSection.dynamicPriceInput}}&quot;).checked.toString()" stepKey="dynamicPriceCheckedValue"/>
26+
<assertEquals stepKey="assertDynamicPrice">
27+
<actualResult type="variable">dynamicPriceCheckedValue</actualResult>
28+
<expectedResult type="string">{{dynamicPrice}}</expectedResult>
29+
</assertEquals>
30+
<executeJS function="return document.querySelector(&quot;{{AdminProductFormBundleSection.dynamicWeightInput}}&quot;).checked.toString()" stepKey="dynamicWeightCheckedValue"/>
31+
<assertEquals stepKey="assertDynamicWeight">
32+
<actualResult type="variable">dynamicWeightCheckedValue</actualResult>
33+
<expectedResult type="string">{{dynamicWeight}}</expectedResult>
34+
</assertEquals>
35+
</actionGroup>
36+
</actionGroups>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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="AdminBundleDynamicAttributesAfterMassUpdateTest">
12+
<annotations>
13+
<features value="Bundle"/>
14+
<stories value="Create/Edit bundle product in Admin"/>
15+
<title value="Verify dynamic attributes of bundle product after mass update"/>
16+
<description value="Verifies that dynamic attributes of bundle product are correctly updated using mass update"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-2884"/>
19+
<group value="Bundle"/>
20+
</annotations>
21+
<before>
22+
<createData entity="ApiFixedBundleProduct" stepKey="createBundleProduct"/>
23+
</before>
24+
<after>
25+
<deleteData createDataKey="createBundleProduct" stepKey="deleteFixedBundleProduct"/>
26+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
27+
</after>
28+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
29+
30+
<actionGroup ref="AdminOpenCatalogProductPageActionGroup" stepKey="goToCatalogProductPage"/>
31+
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="filterBundleProductByName">
32+
<argument name="product" value="ApiFixedBundleProduct"/>
33+
</actionGroup>
34+
35+
<checkOption selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="selectFirstProductFromGrid"/>
36+
<actionGroup ref="AdminClickMassUpdateProductAttributesActionGroup" stepKey="goToUpdateProductAttributesPage"/>
37+
38+
<checkOption selector="{{AdminEditProductAttributesSection.ChangeAttributeDynamicPriceToggle}}" stepKey="toggleToChangeDynamicPrice"/>
39+
<selectOption selector="{{AdminEditProductAttributesSection.AttributeDynamicPrice}}" userInput="No" stepKey="disableDynamicPrice"/>
40+
<checkOption selector="{{AdminEditProductAttributesSection.ChangeAttributeDynamicSKUToggle}}" stepKey="toggleToChangeDynamicSKU"/>
41+
<checkOption selector="{{AdminEditProductAttributesSection.ChangeAttributeDynamicWeightToggle}}" stepKey="toggleToChangeDynamicWeight"/>
42+
<selectOption selector="{{AdminEditProductAttributesSection.AttributeDynamicSKU}}" userInput="No" stepKey="disableDynamicSKU"/>
43+
<selectOption selector="{{AdminEditProductAttributesSection.AttributeDynamicWeight}}" userInput="No" stepKey="disableDynamicWeight"/>
44+
<actionGroup ref="AdminSaveProductsMassAttributesUpdateActionGroup" stepKey="saveMassAttributeUpdate"/>
45+
46+
<actionGroup ref="CliConsumerStartActionGroup" stepKey="startMessageQueueConsumer">
47+
<argument name="consumerName" value="{{AdminProductAttributeUpdateConsumerData.consumerName}}"/>
48+
<argument name="maxMessages" value="{{AdminProductAttributeUpdateConsumerData.messageLimit}}"/>
49+
</actionGroup>
50+
<magentoCLI command="cron:run" stepKey="runCron"/>
51+
52+
<actionGroup ref="OpenProductForEditByClickingRowXColumnYInProductGridActionGroup" stepKey="openProductForEdit"/>
53+
54+
<actionGroup ref="AdminAssertBundleDynamicAttributesOnProductEditPageActionGroup" stepKey="assertBundleProductDynamicAttributesOnEditPage">
55+
<argument name="dynamicSku" value="false"/>
56+
<argument name="dynamicPrice" value="false"/>
57+
<argument name="dynamicWeight" value="false"/>
58+
</actionGroup>
59+
</test>
60+
</tests>

app/code/Magento/Bundle/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@
6666
</argument>
6767
</arguments>
6868
</type>
69+
<type name="Magento\Framework\Data\Form\Element\Fieldset">
70+
<plugin name="Bundle" type="Magento\Bundle\Plugin\Framework\Data\Form\Element\FieldsetPlugin"/>
71+
</type>
6972
</config>

app/code/Magento/Bundle/view/base/templates/product/price/tier_prices.phtml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@
66
?>
77

88
<?php
9-
/** @var \Magento\Framework\Pricing\Render\PriceBox $block */
10-
9+
/**
10+
* @var \Magento\Framework\Pricing\Render\PriceBox $block
11+
* @var \Magento\Framework\Locale\LocaleFormatter $localeFormatter
12+
*/
1113
/** @var \Magento\Bundle\Pricing\Price\TierPrice $tierPriceModel */
1214
$tierPriceModel = $block->getPrice();
1315
$tierPrices = $tierPriceModel->getTierPriceList();
1416
?>
15-
<?php if (count($tierPrices)) : ?>
17+
<?php if (count($tierPrices)):?>
1618
<ul class="<?= $block->escapeHtmlAttr(($block->hasListClass() ? $block->getListClass() : 'prices-tier items')) ?>">
17-
<?php foreach ($tierPrices as $index => $price) : ?>
19+
<?php foreach ($tierPrices as $index => $price): ?>
1820
<li class="item">
1921
<?= /* @noEscape */ __(
2022
'Buy %1 with %2 discount each',
21-
$price['price_qty'],
22-
'<strong class="benefit">' . round($price['percentage_value']) . '%</strong>'
23+
$localeFormatter->formatNumber($price['price_qty']),
24+
'<strong class="benefit">' .
25+
$localeFormatter->formatNumber(round($price['percentage_value'])) .
26+
'%</strong>'
2327
); ?>
2428
</li>
2529
<?php endforeach; ?>

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ define([
211211
}, 0);
212212
toTemplate.data[type] = {
213213
value: value,
214-
formatted: utils.formatPrice(value, format)
214+
formatted: utils.formatPriceLocale(value, format)
215215
};
216216
});
217217

0 commit comments

Comments
 (0)