Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #17557: Replacing deprecated methods for Magento_Security module. (by @tiagosampaio)
 - #17548: Fixed typo in module AdminNotification (by @arnoudhgz)
 - #17549: Fixed typos in module CatalogRule (by @arnoudhgz)
 - #17550: Fixed typo 'Infomation' (by @arnoudhgz)
 - #17528: [Forwardport] AD-HOC feat (Profiler): Allow supplying complex profiler configuration (by @jignesh-baldha)
 - #17519: Added translation comment tags (by @yogeshks)
 - #15542: Add Currency Converter API connecting feature (by @HirokazuNishi)
 - #17495: [Forwardport] Magento 2.2.5: Year-to-date dropdown in Stores>Configuration>General>Reports>Dashboard #17289 (by @ronak2ram)


Fixed GitHub Issues:
 - #15541: Cannot retrieve currency rates for TWD (reported by @HirokazuNishi) has been fixed in #15542 by @HirokazuNishi in 2.3-develop branch
   Related commits:
     1. 5e66404
     2. d682ead

 - #17289: Magento 2.2.5: Year-to-date dropdown in Stores>Configuration>General>Reports>Dashboard (reported by @joshuaflood) has been fixed in #17495 by @ronak2ram in 2.3-develop branch
   Related commits:
     1. cea62ec
     2. 1c70659
  • Loading branch information
Stanislav Idolov authored Aug 14, 2018
2 parents 8c1bd4c + 96021c7 commit 05f9df7
Showing 42 changed files with 274 additions and 119 deletions.
12 changes: 10 additions & 2 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -54,8 +54,16 @@
&& isset($_SERVER['HTTP_ACCEPT'])
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
) {
\Magento\Framework\Profiler::applyConfig(
(isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])) ? $_SERVER['MAGE_PROFILER'] : trim(file_get_contents(BP . '/var/profiler.flag')),
$profilerConfig = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
? $_SERVER['MAGE_PROFILER']
: trim(file_get_contents(BP . '/var/profiler.flag'));

if ($profilerConfig) {
$profilerConfig = json_decode($profilerConfig, true) ?: $profilerConfig;
}

Magento\Framework\Profiler::applyConfig(
$profilerConfig,
BP,
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
);
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public function __construct(
}

/**
* Predispath admin action controller
* Predispatch admin action controller
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ public function getTabTitle()
}

/**
* Returns status flag about this tab can be showen or not
* Returns status flag about this tab can be shown or not
*
* @return bool
* @codeCoverageIgnore
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ protected function _getCpCollectionInstance()
}

/**
* Define Cooser Grid Columns and filters
* Define Chooser Grid Columns and filters
*
* @return $this
*/
Original file line number Diff line number Diff line change
@@ -93,13 +93,13 @@
<argument name="customerAddressVar"/>
</arguments>
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
<see userInput="{{customerVar.firstname}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationFirstName"/>
<see userInput="{{customerVar.lastname}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationLastName"/>
<see userInput="{{customerAddressVar.street[0]}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationStreet"/>
<see userInput="{{customerAddressVar.city}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationCity"/>
<see userInput="{{customerAddressVar.state}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationState"/>
<see userInput="{{customerAddressVar.postcode}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationPostcode"/>
<see userInput="{{customerAddressVar.telephone}}" selector="{{CheckoutPaymentSection.shipToInfomation}}" stepKey="assertShipToInformationTelephone"/>
<see userInput="{{customerVar.firstname}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationFirstName"/>
<see userInput="{{customerVar.lastname}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationLastName"/>
<see userInput="{{customerAddressVar.street[0]}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationStreet"/>
<see userInput="{{customerAddressVar.city}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationCity"/>
<see userInput="{{customerAddressVar.state}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationState"/>
<see userInput="{{customerAddressVar.postcode}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationPostcode"/>
<see userInput="{{customerAddressVar.telephone}}" selector="{{CheckoutPaymentSection.shipToInformation}}" stepKey="assertShipToInformationTelephone"/>
</actionGroup>

<!-- Check shipping method in checkout -->
@@ -108,7 +108,7 @@
<argument name="shippingMethod"/>
</arguments>
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
<see userInput="{{shippingMethod}}" selector="{{CheckoutPaymentSection.shippingMethodInfomation}}" stepKey="assertshippingMethodInfomation"/>
<see userInput="{{shippingMethod}}" selector="{{CheckoutPaymentSection.shippingMethodInformation}}" stepKey="assertshippingMethodInformation"/>
</actionGroup>

<!-- Checkout select Check/Money Order payment -->
Original file line number Diff line number Diff line change
@@ -36,8 +36,8 @@
<element name="ProductItemByName" type="text" selector="//div[@class='product-item-details']//strong[@class='product-item-name'][text()='{{var1}}']" parameterized="true" />
<element name="ProductOptionsByProductItemName" type="text" selector="//div[@class='product-item-details']//strong[@class='product-item-name'][text()='{{var1}}']//ancestor::div[@class='product-item-details']//div[@class='product options']" parameterized="true" />
<element name="ProductOptionsActiveByProductItemName" type="text" selector="//div[@class='product-item-details']//strong[@class='product-item-name'][text()='{{var1}}']//ancestor::div[@class='product-item-details']//div[@class='product options active']" parameterized="true" />
<element name="shipToInfomation" type="text" selector="//div[@class='ship-to']//div[@class='shipping-information-content']" />
<element name="shippingMethodInfomation" type="text" selector="//div[@class='ship-via']//div[@class='shipping-information-content']" />
<element name="shipToInformation" type="text" selector="//div[@class='ship-to']//div[@class='shipping-information-content']" />
<element name="shippingMethodInformation" type="text" selector="//div[@class='ship-via']//div[@class='shipping-information-content']" />
<element name="paymentMethodTitle" type="text" selector=".payment-method-title span" />
<element name="productOptionsByProductItemPrice" type="text" selector="//div[@class='product-item-inner']//div[@class='subtotal']//span[@class='price'][contains(.,'{{var1}}')]//ancestor::div[@class='product-item-details']//div[@class='product options']" parameterized="true"/>
<element name="productOptionsActiveByProductItemPrice" type="text" selector="//div[@class='subtotal']//span[@class='price'][contains(.,'{{var1}}')]//ancestor::div[@class='product-item-details']//div[@class='product options active']" parameterized="true"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Directory\Model\Currency\Import;

class CurrencyConverterApi extends AbstractImport
{
/**
* @var string
*/
const CURRENCY_CONVERTER_URL = 'http://free.currencyconverterapi.com/api/v3/convert?q={{CURRENCY_FROM}}_{{CURRENCY_TO}}&compact=ultra'; //@codingStandardsIgnoreLine

/**
* Http Client Factory
*
* @var \Magento\Framework\HTTP\ZendClientFactory
*/
private $httpClientFactory;

/**
* Core scope config
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $scopeConfig;

/**
* Initialize dependencies
*
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
*/
public function __construct(
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
) {
parent::__construct($currencyFactory);
$this->scopeConfig = $scopeConfig;
$this->httpClientFactory = $httpClientFactory;
}

/**
* {@inheritdoc}
*/
public function fetchRates()
{
$data = [];
$currencies = $this->_getCurrencyCodes();
$defaultCurrencies = $this->_getDefaultCurrencyCodes();

foreach ($defaultCurrencies as $currencyFrom) {
if (!isset($data[$currencyFrom])) {
$data[$currencyFrom] = [];
}
$data = $this->convertBatch($data, $currencyFrom, $currencies);
ksort($data[$currencyFrom]);
}
return $data;
}

/**
* Return currencies convert rates in batch mode
*
* @param array $data
* @param string $currencyFrom
* @param array $currenciesTo
* @return array
*/
private function convertBatch($data, $currencyFrom, $currenciesTo)
{
foreach ($currenciesTo as $to) {
set_time_limit(0);
try {
$url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, self::CURRENCY_CONVERTER_URL);
$url = str_replace('{{CURRENCY_TO}}', $to, $url);
$response = $this->getServiceResponse($url);
if ($currencyFrom == $to) {
$data[$currencyFrom][$to] = $this->_numberFormat(1);
} else {
if (empty($response)) {
$this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $to);
$data[$currencyFrom][$to] = null;
} else {
$data[$currencyFrom][$to] = $this->_numberFormat(
(double)$response[$currencyFrom . '_' . $to]
);
}
}
} finally {
ini_restore('max_execution_time');
}
}

return $data;
}

/**
* Get Fixer.io service response
*
* @param string $url
* @param int $retry
* @return array
*/
private function getServiceResponse($url, $retry = 0)
{
/** @var \Magento\Framework\HTTP\ZendClient $httpClient */
$httpClient = $this->httpClientFactory->create();
$response = [];

try {
$jsonResponse = $httpClient->setUri(
$url
)->setConfig(
[
'timeout' => $this->scopeConfig->getValue(
'currency/currencyconverterapi/timeout',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
),
]
)->request(
'GET'
)->getBody();

$response = json_decode($jsonResponse, true);
} catch (\Exception $e) {
if ($retry == 0) {
$response = $this->getServiceResponse($url, 1);
}
}
return $response;
}

/**
* {@inheritdoc}
*/
protected function _convert($currencyFrom, $currencyTo)
{
return 1;
}
}
6 changes: 6 additions & 0 deletions app/code/Magento/Directory/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -52,6 +52,12 @@
<label>Connection Timeout in Seconds</label>
</field>
</group>
<group id="currencyconverterapi" translate="label" sortOrder="45" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Currency Converter API</label>
<field id="timeout" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Connection Timeout in Seconds</label>
</field>
</group>
<group id="import" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Scheduled Import Settings</label>
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
3 changes: 3 additions & 0 deletions app/code/Magento/Directory/etc/config.xml
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@
<webservicex>
<timeout>100</timeout>
</webservicex>
<currencyconverterapi>
<timeout>100</timeout>
</currencyconverterapi>
<import>
<enabled>0</enabled>
<error_email />
4 changes: 4 additions & 0 deletions app/code/Magento/Directory/etc/di.xml
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@
<item name="label" xsi:type="string" translatable="true">Fixer.io</item>
<item name="class" xsi:type="string">Magento\Directory\Model\Currency\Import\FixerIo</item>
</item>
<item name="currencyconverterapi" xsi:type="array">
<item name="label" xsi:type="string" translatable="true">Currency Converter API</item>
<item name="class" xsi:type="string">Magento\Directory\Model\Currency\Import\CurrencyConverterApi</item>
</item>
</argument>
</arguments>
</type>
Original file line number Diff line number Diff line change
@@ -72,12 +72,12 @@
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="seeBilllingPostcode" />
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="seeBilllingTelephone" />
<!-- Check that "Ship To" block contains correct information -->
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.firstName}}" stepKey="seeShipToFirstName" />
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.lastName}}" stepKey="seeShipToLastName" />
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeShipToStreet" />
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.city}}" stepKey="seeShipToCity" />
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.state}}" stepKey="seeShipToState" />
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="seeShipToPostcode" />
<see selector="{{CheckoutPaymentSection.shipToInfomation}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="seeShipToTelephone" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.firstName}}" stepKey="seeShipToFirstName" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.lastName}}" stepKey="seeShipToLastName" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeShipToStreet" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.city}}" stepKey="seeShipToCity" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.state}}" stepKey="seeShipToState" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="seeShipToPostcode" />
<see selector="{{CheckoutPaymentSection.shipToInformation}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="seeShipToTelephone" />
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -23,9 +23,8 @@ protected function _getElementHtml(AbstractElement $element)
{
$_months = [];
for ($i = 1; $i <= 12; $i++) {
$_months[$i] = $this->_localeDate->date(mktime(null, null, null, $i))->format('m');
$_months[$i] = $this->_localeDate->date(mktime(null, null, null, $i, 1))->format('m');
}

$_days = [];
for ($i = 1; $i <= 31; $i++) {
$_days[$i] = $i < 10 ? '0' . $i : $i;
10 changes: 6 additions & 4 deletions app/code/Magento/Search/Controller/Adminhtml/Synonyms/Delete.php
Original file line number Diff line number Diff line change
@@ -60,16 +60,18 @@ public function execute()
/** @var \Magento\Search\Model\SynonymGroup $synGroupModel */
$synGroupModel = $this->synGroupRepository->get($id);
$this->synGroupRepository->delete($synGroupModel);
$this->messageManager->addSuccess(__('The synonym group has been deleted.'));
$this->messageManager->addSuccessMessage(__('The synonym group has been deleted.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$this->logger->error($e);
} catch (\Exception $e) {
$this->messageManager->addError(__('An error was encountered while performing delete operation.'));
$this->messageManager->addErrorMessage(
__('An error was encountered while performing delete operation.')
);
$this->logger->error($e);
}
} else {
$this->messageManager->addError(__('We can\'t find a synonym group to delete.'));
$this->messageManager->addErrorMessage(__('We can\'t find a synonym group to delete.'));
}

return $resultRedirect->setPath('*/*/');
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ public function execute()

// 2. Initial checking
if ($groupId && (!$synGroup->getGroupId())) {
$this->messageManager->addError(__('This synonyms group no longer exists.'));
$this->messageManager->addErrorMessage(__('This synonyms group no longer exists.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('*/*/');
Original file line number Diff line number Diff line change
@@ -72,17 +72,17 @@ public function execute()
$this->synGroupRepository->delete($synonymGroup);
$deletedItems++;
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
}
}
if ($deletedItems != 0) {
if ($collectionSize != $deletedItems) {
$this->messageManager->addError(
$this->messageManager->addErrorMessage(
__('Failed to delete %1 synonym group(s).', $collectionSize - $deletedItems)
);
}

$this->messageManager->addSuccess(
$this->messageManager->addSuccessMessage(
__('A total of %1 synonym group(s) have been deleted.', $deletedItems)
);
}
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public function execute()
$synGroup = $this->synGroupRepository->get($synGroupId);

if (!$synGroup->getGroupId() && $synGroupId) {
$this->messageManager->addError(__('This synonym group no longer exists.'));
$this->messageManager->addErrorMessage(__('This synonym group no longer exists.'));
return $resultRedirect->setPath('*/*/');
}

6 changes: 3 additions & 3 deletions app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php
Original file line number Diff line number Diff line change
@@ -23,16 +23,16 @@ public function execute()
$model = $this->_objectManager->create(\Magento\Search\Model\Query::class);
$model->setId($id);
$model->delete();
$this->messageManager->addSuccess(__('You deleted the search.'));
$this->messageManager->addSuccessMessage(__('You deleted the search.'));
$resultRedirect->setPath('search/*/');
return $resultRedirect;
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$resultRedirect->setPath('search/*/edit', ['id' => $this->getRequest()->getParam('id')]);
return $resultRedirect;
}
}
$this->messageManager->addError(__('We can\'t find a search term to delete.'));
$this->messageManager->addErrorMessage(__('We can\'t find a search term to delete.'));
$resultRedirect->setPath('search/*/');
return $resultRedirect;
}
Loading

0 comments on commit 05f9df7

Please sign in to comment.