Skip to content

Commit

Permalink
Merge branch '2.4-develop' into add-ReloadPageActionGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Usik2203 authored Oct 17, 2020
2 parents 52a288b + c0f3dfb commit 9de5f78
Show file tree
Hide file tree
Showing 499 changed files with 13,195 additions and 2,319 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,json}]
indent_size = 2

[{composer, auth}.json]
indent_size = 4
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
<element name="success" type="text" selector="#system_messages div.message-success"/>
<element name="warning" type="text" selector="#system_messages div.message-warning"/>
<element name="notice" type="text" selector="#system_messages div.message-notice"/>
<element name="info" type="text" selector="#system_messages div.message-info"/>
<element name="viewDetailsLink" type="button" selector="//div[contains(@class, 'message-system-short')]/a[contains(text(), 'View Details')]" timeout="30"/>
</section>
</sections>
11 changes: 10 additions & 1 deletion app/code/Magento/Analytics/Model/ReportUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class ReportUrlProvider
*/
private $urlReportConfigPath = 'analytics/url/report';

/**
* Path to Advanced Reporting documentation URL.
*
* @var string
*/
private $urlReportDocConfigPath = 'analytics/url/documentation';

/**
* @param AnalyticsToken $analyticsToken
* @param OTPRequest $otpRequest
Expand Down Expand Up @@ -80,13 +87,15 @@ public function getUrl()
));
}

$url = $this->config->getValue($this->urlReportConfigPath);
if ($this->analyticsToken->isTokenExist()) {
$url = $this->config->getValue($this->urlReportConfigPath);
$otp = $this->otpRequest->call();
if ($otp) {
$query = http_build_query(['otp' => $otp], '', '&');
$url .= '?' . $query;
}
} else {
$url = $this->config->getValue($this->urlReportDocConfigPath);
}

return $url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

<switchToNextTab stepKey="switchToNewTab"/>
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
<seeInCurrentUrl url="reports/advanced-reporting" stepKey="seeAssertAdvancedReportingPageUrl"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,10 @@ class ReportUrlProviderTest extends TestCase
*/
private $flagManagerMock;

/**
* @var ObjectManagerHelper
*/
private $objectManagerHelper;

/**
* @var ReportUrlProvider
*/
private $reportUrlProvider;

/**
* @var string
*/
private $urlReportConfigPath = 'path/url/report';
private $model;

/**
* @return void
Expand All @@ -71,35 +61,36 @@ protected function setUp(): void

$this->flagManagerMock = $this->createMock(FlagManager::class);

$this->objectManagerHelper = new ObjectManagerHelper($this);
$objectManagerHelper = new ObjectManagerHelper($this);

$this->reportUrlProvider = $this->objectManagerHelper->getObject(
$this->model = $objectManagerHelper->getObject(
ReportUrlProvider::class,
[
'config' => $this->configMock,
'analyticsToken' => $this->analyticsTokenMock,
'otpRequest' => $this->otpRequestMock,
'flagManager' => $this->flagManagerMock,
'urlReportConfigPath' => $this->urlReportConfigPath,
]
);
}

/**
* @param bool $isTokenExist
* @param string|null $otp If null OTP was not received.
* @param string $configPath
* @return void
*
* @dataProvider getUrlDataProvider
*/
public function testGetUrl($isTokenExist, $otp)
public function testGetUrl(bool $isTokenExist, ?string $otp, string $configPath): void
{
$reportUrl = 'https://example.com/report';
$url = '';

$this->configMock
->expects($this->once())
->method('getValue')
->with($this->urlReportConfigPath)
->with($configPath)
->willReturn($reportUrl);
$this->analyticsTokenMock
->expects($this->once())
Expand All @@ -114,18 +105,19 @@ public function testGetUrl($isTokenExist, $otp)
if ($isTokenExist && $otp) {
$url = $reportUrl . '?' . http_build_query(['otp' => $otp], '', '&');
}
$this->assertSame($url ?: $reportUrl, $this->reportUrlProvider->getUrl());

$this->assertSame($url ?: $reportUrl, $this->model->getUrl());
}

/**
* @return array
*/
public function getUrlDataProvider()
public function getUrlDataProvider(): array
{
return [
'TokenDoesNotExist' => [false, null],
'TokenExistAndOtpEmpty' => [true, null],
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'],
'TokenDoesNotExist' => [false, null, 'analytics/url/documentation'],
'TokenExistAndOtpEmpty' => [true, null, 'analytics/url/report'],
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab', 'analytics/url/report'],
];
}

Expand All @@ -140,6 +132,6 @@ public function testGetUrlWhenSubscriptionUpdateRunning()
->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
->willReturn('http://store.com');
$this->expectException(SubscriptionUpdateException::class);
$this->reportUrlProvider->getUrl();
$this->model->getUrl();
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Analytics/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<otp>https://advancedreporting.rjmetrics.com/otp</otp>
<report>https://advancedreporting.rjmetrics.com/report</report>
<notify_data_changed>https://advancedreporting.rjmetrics.com/report</notify_data_changed>
<documentation>https://docs.magento.com/user-guide/reports/advanced-reporting.html</documentation>
</url>
<integration_name>Magento Analytics user</integration_name>
<general>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminBulkDetailsModalSection">
<element name="descriptionValue" type="text" selector="//aside//div[@data-index='description']//span[@name='description']"/>
<element name="summaryValue" type="text" selector="//aside//div[@data-index='summary']//span[@name='summary']" />
<element name="startTimeValue" type="text" selector="//aside//div[@data-index='start_time']//span[@name='start_time']" />
</section>
</sections>
1 change: 1 addition & 0 deletions app/code/Magento/Backend/view/adminhtml/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<body>
<attribute name="id" value="html-body"/>
<block name="require.js" class="Magento\Backend\Block\Page\RequireJs" template="Magento_Backend::page/js/require_js.phtml"/>
<block class="Magento\Framework\View\Element\Template" name="head.additional" template="Magento_Backend::page/container.phtml"/>
<referenceContainer name="global.notices">
<block class="Magento\Backend\Block\Page\Notices" name="global_notices" as="global_notices" template="Magento_Backend::page/notices.phtml"/>
</referenceContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?= $block->getChildHtml(); ?>
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<label translate="true">Status</label>
<dataScope>status</dataScope>
<imports>
<link name="visible">componentType = column, index = ${ $.index }:visible</link>
<link name="visible">ns = ${ $.ns }, index = ${ $.index }:visible</link>
</imports>
</settings>
</filterSelect>
Expand Down
24 changes: 14 additions & 10 deletions app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function __construct(
}

/**
* Construct block
*
* @return void
*/
protected function _construct()
Expand All @@ -51,6 +53,14 @@ protected function _construct()

parent::_construct();

$this->buttonList->update('save', 'label', __('Save Attribute'));
$this->buttonList->update('save', 'class', 'save primary');
$this->buttonList->update(
'save',
'data_attribute',
['mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']]]
);

if ($this->getRequest()->getParam('popup')) {
$this->buttonList->remove('back');
if ($this->getRequest()->getParam('product_tab') != 'variations') {
Expand All @@ -64,6 +74,8 @@ protected function _construct()
100
);
}
$this->buttonList->update('reset', 'level', 10);
$this->buttonList->update('save', 'class', 'save action-secondary');
} else {
$this->addButton(
'save_and_edit_button',
Expand All @@ -79,14 +91,6 @@ protected function _construct()
);
}

$this->buttonList->update('save', 'label', __('Save Attribute'));
$this->buttonList->update('save', 'class', 'save primary');
$this->buttonList->update(
'save',
'data_attribute',
['mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']]]
);

$entityAttribute = $this->_coreRegistry->registry('entity_attribute');
if (!$entityAttribute || !$entityAttribute->getIsUserDefined()) {
$this->buttonList->remove('delete');
Expand All @@ -96,14 +100,14 @@ protected function _construct()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region = 'toolbar')
{
if ($this->getRequest()->getParam('popup')) {
$region = 'header';
}
parent::addButton($buttonId, $data, $level, $sortOrder, $region);
return parent::addButton($buttonId, $data, $level, $sortOrder, $region);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Block/Product/ListProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function getIdentities()
$identities[] = $item->getIdentities();
}
}
$identities = array_merge(...$identities);
$identities = array_merge([], ...$identities);

return $identities;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ public function getItems()
*/
public function getIdentities()
{
$identities = [[]];
$identities = [];
foreach ($this->getItems() as $item) {
$identities[] = $item->getIdentities();
}
return array_merge(...$identities);
return array_merge([], ...$identities);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ public function getItemLimit($type = '')
*/
public function getIdentities()
{
$identities = array_map(function (DataObject $item) {
return $item->getIdentities();
}, $this->getItems()) ?: [[]];

return array_merge(...$identities);
$identities = [];
foreach ($this->getItems() as $item) {
$identities[] = $item->getIdentities();
}
return array_merge([], ...$identities);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

namespace Magento\Catalog\Block\Product\View\Options;

use Magento\Catalog\Pricing\Price\BasePrice;
use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
use Magento\Framework\App\ObjectManager;

/**
* Product options section abstract block.
Expand Down Expand Up @@ -47,20 +50,29 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
*/
protected $_catalogHelper;

/**
* @var CalculateCustomOptionCatalogRule
*/
private $calculateCustomOptionCatalogRule;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
* @param \Magento\Catalog\Helper\Data $catalogData
* @param array $data
* @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
\Magento\Catalog\Helper\Data $catalogData,
array $data = []
array $data = [],
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
) {
$this->pricingHelper = $pricingHelper;
$this->_catalogHelper = $catalogData;
$this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -162,6 +174,19 @@ protected function _formatPrice($value, $flag = true)
$priceStr = $sign;

$customOptionPrice = $this->getProduct()->getPriceInfo()->getPrice('custom_option_price');
$isPercent = (bool) $value['is_percent'];

if (!$isPercent) {
$catalogPriceValue = $this->calculateCustomOptionCatalogRule->execute(
$this->getProduct(),
(float)$value['pricing_value'],
$isPercent
);
if ($catalogPriceValue !== null) {
$value['pricing_value'] = $catalogPriceValue;
}
}

$context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
$optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
$priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(
Expand Down
Loading

0 comments on commit 9de5f78

Please sign in to comment.