Skip to content

Resolve "Layered Navigation Price Step" in Category Form display wrong currency issue25970 #25971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminAssertCurrencySymbolCategoryFormActionGroup">
<annotations>
<description>Check display currency symbol in category form</description>
</annotations>
<arguments>
<argument name="baseCurrency" type="string"/>
</arguments>
<click selector="{{AdminCategoryDisplaySettingsSection.settingsHeader}}" stepKey="clickDisplaySettingHeader"/>
<grabTextFrom selector="{{AdminCategoryDisplaySettingsSection.currencySymbol}}" stepKey="currencySymbol"/>
<assertEquals stepKey="assertCurrencySymbol">
<expectedResult type="string">{{baseCurrency}}</expectedResult>
<actualResult type="variable">currencySymbol</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminCatalogNavigateToCategoryPageActionGroup">
<annotations>
<description>Navigate to Category Page</description>
</annotations>
<!--Navigate To Category Page-->
<amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/>
<waitForPageLoad stepKey="waitForPageToLoaded"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<section name="AdminCategoryDisplaySettingsSection">
<element name="settingsHeader" type="button" selector="//*[contains(text(),'Display Settings')]" timeout="30"/>
<element name="displayMode" type="button" selector="//*[@name='display_mode']"/>
<element name="currencySymbol" type="text" selector=".admin__field[data-index=filter_price_range_group] .admin__addon-prefix span"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCatalogCheckCategoryFormWithChangedBaseCurrencyTest">
<annotations>
<features value="Catalog"/>
<stories value="Create/Edit Category in Admin"/>
<title value="Check category form with changed base currency"/>
<description value="Check category form with base currency which is different from USD"/>
<severity value="MINOR"/>
<group value="category"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
<!--Set Base Currency to Euro-->
<magentoCLI command="config:set {{SetCurrencyEURBaseConfig.path}} {{SetCurrencyEURBaseConfig.value}}" stepKey="setCurrencyBaseEUR"/>
<magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setAllowedCurrencyEURandUSD"/>
<magentoCLI command="config:set {{SetDefaultCurrencyEURConfig.path}} {{SetDefaultCurrencyEURConfig.value}}" stepKey="setCurrencyDefaultEUR"/>
</before>
<after>
<!--Reset configurations-->
<magentoCLI command="config:set {{SetCurrencyUSDBaseConfig.path}} {{SetCurrencyUSDBaseConfig.value}}" stepKey="setCurrencyBaseUSD"/>
<magentoCLI command="config:set {{SetDefaultCurrencyUSDConfig.path}} {{SetDefaultCurrencyUSDConfig.value}}" stepKey="setCurrencyDefaultUSD"/>
<magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setAllowedCurrencyUSD"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<actionGroup ref="AdminCatalogNavigateToCategoryPageActionGroup" stepKey="navigateToCategoryPage"/>
<actionGroup ref="AdminAssertCurrencySymbolCategoryFormActionGroup" stepKey="assertCurrencySymbol">
<argument name="baseCurrency" value="€"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Catalog\Ui\Component\Form\Field;

use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Form\Field;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Exception\LocalizedException;

/***
* Render Filter Price Range Field
*
* Class FilterPriceRange
*/
class FilterPriceRange extends Field
{
/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* FilterPriceRange constructor.
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = [],
array $data = []
) {
$this->storeManager = $storeManager;
parent::__construct($context, $uiComponentFactory, $components, $data);
}

/**
* Add Currency Symbol To Field
*
* @return void
* @throws LocalizedException
*/
public function prepare()
{
parent::prepare();
$config = $this->getData('config');
$config['addbefore'] = $this->storeManager->getStore()->getBaseCurrency()->getCurrencySymbol();
$this->setData('config', $config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
<item name="breakLine" xsi:type="boolean">true</item>
</item>
</argument>
<field name="filter_price_range" formElement="input">
<field name="filter_price_range" formElement="input" class="Magento\Catalog\Ui\Component\Form\Field\FilterPriceRange">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">category</item>
Expand All @@ -354,7 +354,6 @@
<additionalClasses>
<class name="admin__field-small">true</class>
</additionalClasses>
<addBefore>$</addBefore>
<label translate="true">Layered Navigation Price Step</label>
</settings>
</field>
Expand Down