-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added product list price modifier to modify price attributes data to …
…price format
- Loading branch information
Vaha
committed
Mar 12, 2020
1 parent
047f5b9
commit d81d1d4
Showing
15 changed files
with
359 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductGridCellActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?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="AssertAdminProductGridCellActionGroup"> | ||
<annotations> | ||
<description>Checks value for Admin Product Grid cell by provided row and column.</description> | ||
</annotations> | ||
<arguments> | ||
<argument name="row" type="string" defaultValue="1"/> | ||
<argument name="column" type="string" defaultValue="Name"/> | ||
<argument name="value" type="string" defaultValue="1"/> | ||
</arguments> | ||
|
||
<see selector="{{AdminProductGridSection.productGridCell(row,column)}}" userInput="{{value}}" stepKey="seeProductGridCellWithProvidedValue"/> | ||
</actionGroup> | ||
</actionGroups> |
21 changes: 21 additions & 0 deletions
21
...de/Magento/Catalog/Test/Mftf/ActionGroup/CheckAdminProductGridColumnOptionActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?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="CheckAdminProductGridColumnOptionActionGroup"> | ||
<annotations> | ||
<description>Checks Admin Product Grid 'Columns' option.</description> | ||
</annotations> | ||
<arguments> | ||
<argument name="optionName" type="string" defaultValue="Name"/> | ||
</arguments> | ||
|
||
<checkOption selector="{{AdminProductGridFilterSection.viewColumnOption(optionName)}}" stepKey="checkColumn"/> | ||
</actionGroup> | ||
</actionGroups> |
19 changes: 19 additions & 0 deletions
19
app/code/Magento/Catalog/Test/Mftf/ActionGroup/ClearFiltersAdminProductGridActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="ClearFiltersAdminProductGridActionGroup"> | ||
<annotations> | ||
<description>Clicks on 'Clear Filters'.</description> | ||
</annotations> | ||
|
||
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/> | ||
<waitForPageLoad stepKey="waitForGridLoad"/> | ||
</actionGroup> | ||
</actionGroups> |
18 changes: 18 additions & 0 deletions
18
app/code/Magento/Catalog/Test/Mftf/ActionGroup/ResetAdminProductGridColumnsActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?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="ResetAdminProductGridColumnsActionGroup"> | ||
<annotations> | ||
<description>Clicks 'reset' for Admin Product Grid 'Columns' dropdown.</description> | ||
</annotations> | ||
|
||
<click selector="{{AdminProductGridFilterSection.resetGridColumns}}" stepKey="resetProductGridColumns"/> | ||
</actionGroup> | ||
</actionGroups> |
18 changes: 18 additions & 0 deletions
18
...agento/Catalog/Test/Mftf/ActionGroup/ToggleAdminProductGridColumnsDropdownActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?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="ToggleAdminProductGridColumnsDropdownActionGroup"> | ||
<annotations> | ||
<description>Toggles Admin Product Grid 'Columns' dropdown.</description> | ||
</annotations> | ||
|
||
<click selector="{{AdminProductGridFilterSection.columnsDropdown}}" stepKey="toggleColumnsDropdown"/> | ||
</actionGroup> | ||
</actionGroups> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckProductListPriceAttributesTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?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="AdminCheckProductListPriceAttributesTest"> | ||
<annotations> | ||
<stories value="Check price attributes values on Admin Product List"/> | ||
<title value="Check price attributes values on Admin Product List."/> | ||
<description value="Login as admin, create simple product, add cost, special price. Go to Admin | ||
Product List page filter grid by created product, add mentioned columns to grid, check values."/> | ||
<group value="catalog"/> | ||
</annotations> | ||
<before> | ||
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/> | ||
<createData entity="SimpleOutOfStockProductWithSpecialPriceAndCost" stepKey="createSimpleProduct"/> | ||
|
||
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="adminOpenProductIndexPage"/> | ||
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterProductGridByCreatedSimpleProductSku"> | ||
<argument name="product" value="$$createSimpleProduct$$"/> | ||
</actionGroup> | ||
</before> | ||
<after> | ||
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="clearFiltersAdminProductGrid"/> | ||
<actionGroup ref="ToggleAdminProductGridColumnsDropdownActionGroup" stepKey="openToResetColumnsDropdown"/> | ||
<actionGroup ref="ResetAdminProductGridColumnsActionGroup" stepKey="resetAdminProductGridColumns"/> | ||
|
||
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> | ||
<actionGroup ref="logout" stepKey="logout"/> | ||
<!-- Reindex invalidated indices after product attribute has been created/deleted --> | ||
<actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> | ||
</after> | ||
|
||
<actionGroup ref="ToggleAdminProductGridColumnsDropdownActionGroup" stepKey="openColumnsDropdown"/> | ||
<actionGroup ref="CheckAdminProductGridColumnOptionActionGroup" stepKey="checkSpecialPriceOption"> | ||
<argument name="optionName" value="Special Price"/> | ||
</actionGroup> | ||
<actionGroup ref="CheckAdminProductGridColumnOptionActionGroup" stepKey="checkCostOption"> | ||
<argument name="optionName" value="Cost"/> | ||
</actionGroup> | ||
<actionGroup ref="ToggleAdminProductGridColumnsDropdownActionGroup" stepKey="closeColumnsDropdown"/> | ||
|
||
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seePrice"> | ||
<argument name="row" value="1"/> | ||
<argument name="column" value="Price"/> | ||
<argument name="value" value="${{SimpleOutOfStockProduct.price}}"/> | ||
</actionGroup> | ||
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeCorrectSpecialPrice"> | ||
<argument name="row" value="1"/> | ||
<argument name="column" value="Special Price"/> | ||
<argument name="value" value="${{ApiProductSpecialPrice.value}}"/> | ||
</actionGroup> | ||
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeCorrectCost"> | ||
<argument name="row" value="1"/> | ||
<argument name="column" value="Cost"/> | ||
<argument name="value" value="${{ApiProductCost.value}}"/> | ||
</actionGroup> | ||
</test> | ||
</tests> |
105 changes: 105 additions & 0 deletions
105
app/code/Magento/Catalog/Ui/DataProvider/Product/Modifier/PriceAttributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Ui\DataProvider\Product\Modifier; | ||
|
||
use Magento\Framework\Currency; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\Locale\CurrencyInterface; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Ui\DataProvider\Modifier\ModifierInterface; | ||
|
||
/** | ||
* Modify product listing price attributes | ||
*/ | ||
class PriceAttributes implements ModifierInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $priceAttributeList; | ||
|
||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* @var CurrencyInterface | ||
*/ | ||
private $localeCurrency; | ||
|
||
/** | ||
* PriceAttributes constructor. | ||
* | ||
* @param StoreManagerInterface $storeManager | ||
* @param CurrencyInterface $localeCurrency | ||
* @param array $priceAttributeList | ||
*/ | ||
public function __construct( | ||
StoreManagerInterface $storeManager, | ||
CurrencyInterface $localeCurrency, | ||
array $priceAttributeList = [] | ||
) { | ||
$this->storeManager = $storeManager; | ||
$this->localeCurrency = $localeCurrency; | ||
$this->priceAttributeList = $priceAttributeList; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function modifyData(array $data): array | ||
{ | ||
if (empty($data) || empty($this->priceAttributeList)) { | ||
return $data; | ||
} | ||
|
||
foreach ($data['items'] as &$item) { | ||
foreach ($this->priceAttributeList as $priceAttribute) { | ||
if (isset($item[$priceAttribute])) { | ||
$item[$priceAttribute] = $this->getCurrency()->toCurrency(sprintf("%f", $item[$priceAttribute])); | ||
} | ||
} | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function modifyMeta(array $meta): array | ||
{ | ||
return $meta; | ||
} | ||
|
||
/** | ||
* Retrieve store | ||
* | ||
* @return StoreInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
private function getStore(): StoreInterface | ||
{ | ||
return $this->storeManager->getStore(); | ||
} | ||
|
||
/** | ||
* Retrieve currency | ||
* | ||
* @return Currency | ||
* @throws NoSuchEntityException | ||
*/ | ||
private function getCurrency(): Currency | ||
{ | ||
$baseCurrencyCode = $this->getStore()->getBaseCurrencyCode(); | ||
|
||
return $this->localeCurrency->getCurrency($baseCurrencyCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/code/Magento/Msrp/Test/Mftf/Data/CustomAttributeData.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> | ||
<entity name="ApiProductMsrp" type="custom_attribute"> | ||
<data key="attribute_code">msrp</data> | ||
<data key="value">111.11</data> | ||
</entity> | ||
</entities> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
--> | ||
|
||
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> | ||
<entity name="SimpleOutOfStockProductWithSpecialPriceCostAndMsrp" type="product" extends="SimpleOutOfStockProduct"> | ||
<requiredEntity type="custom_attribute_array">ApiProductSpecialPrice</requiredEntity> | ||
<requiredEntity type="custom_attribute_array">ApiProductCost</requiredEntity> | ||
<requiredEntity type="custom_attribute_array">ApiProductMsrp</requiredEntity> | ||
</entity> | ||
</entities> |
29 changes: 29 additions & 0 deletions
29
app/code/Magento/Msrp/Test/Mftf/Test/AdminCheckProductListPriceAttributesTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?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="AdminCheckProductListPriceAttributesTest"> | ||
<annotations> | ||
<group value="msrp"/> | ||
</annotations> | ||
<before> | ||
<createData entity="SimpleOutOfStockProductWithSpecialPriceCostAndMsrp" stepKey="createSimpleProduct"/> | ||
</before> | ||
|
||
<actionGroup ref="CheckAdminProductGridColumnOptionActionGroup" stepKey="checkMsrpOption" after="checkCostOption"> | ||
<argument name="optionName" value="Minimum Advertised Price"/> | ||
</actionGroup> | ||
|
||
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="seeCorrectMsrp" after="seeCorrectCost"> | ||
<argument name="row" value="1"/> | ||
<argument name="column" value="Minimum Advertised Price"/> | ||
<argument name="value" value="${{ApiProductMsrp.value}}"/> | ||
</actionGroup> | ||
</test> | ||
</tests> |
Oops, something went wrong.