Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-devel…
Browse files Browse the repository at this point in the history
…op daily delivery

Accepted Community Pull Requests:
 - #26784: [Forward Port PR-14344] Fix generating product URL rewrites for anchor categories (by @hostep)
 - #27261: 20472 added product list price modifier (by @sergiy-v)
 - #27284: Fix static test failures for class annotaions (by @ihor-sviziev)
 - #27274: MFTF: Create Account tests (Success & Failure) with `extend` (by @lbajsarowicz)
 - #27281: TYPO: Fix annoying typo in Quantity word (by @lbajsarowicz)
 - #27277: MFTF: Rename and rewrite Test that fake expired session (by @lbajsarowicz)
 - #26348: Fixed #26345 Reorder in Admin panel leads to report page in case of changed product custom option max characters (by @cedmudit)
 - #26746: In System/Export controlers use MessageManager instead of throwing exceptions (by @pmarki)
 - #27249: Update Frontend Development Workflow type's comment to be clearer (by @navarr)


Fixed GitHub Issues:
 - #4112: Wrong parent category url_key in URL (reported by @bh-ref) has been fixed in #26784 by @hostep in 2.4-develop branch
   Related commits:
     1. cb685d1
     2. acb8642
     3. 97258e1
     4. 6cf26dc
     5. 0b94121
     6. b0c0c59
     7. 28fa345
     8. bf514b0

 - #11615: URL Rewrites vs multiple storeviews - a never ending battle (reported by @hostep) has been fixed in #26784 by @hostep in 2.4-develop branch
   Related commits:
     1. cb685d1
     2. acb8642
     3. 97258e1
     4. 6cf26dc
     5. 0b94121
     6. b0c0c59
     7. 28fa345
     8. bf514b0

 - #11616: URL Rewrites vs multiple storeviews - too many rewrites are being generated (reported by @hostep) has been fixed in #26784 by @hostep in 2.4-develop branch
   Related commits:
     1. cb685d1
     2. acb8642
     3. 97258e1
     4. 6cf26dc
     5. 0b94121
     6. b0c0c59
     7. 28fa345
     8. bf514b0

 - #25124: Magento 2.3 Wrong product url for anchor categories for multiple storeviews (reported by @juharintanen) has been fixed in #26784 by @hostep in 2.4-develop branch
   Related commits:
     1. cb685d1
     2. acb8642
     3. 97258e1
     4. 6cf26dc
     5. 0b94121
     6. b0c0c59
     7. 28fa345
     8. bf514b0

 - #26393: Product category url rewrite missing storeview specific url_key (reported by @juhanihaapala) has been fixed in #26784 by @hostep in 2.4-develop branch
   Related commits:
     1. cb685d1
     2. acb8642
     3. 97258e1
     4. 6cf26dc
     5. 0b94121
     6. b0c0c59
     7. 28fa345
     8. bf514b0

 - #20472: Special Price shown without currency symbol in magento backoffice (reported by @XxXgeoXxX) has been fixed in #27261 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. d81d1d4

 - #20906: Magento backend catalog "Cost" without currency symbol (reported by @mage2pratik) has been fixed in #27261 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. d81d1d4

 - #21910: Magento backend catalog "MSRP" without currency symbol (reported by @mage2pratik) has been fixed in #27261 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. d81d1d4

 - #26345: Reorder in Admin panel leads to report page in case of changed product custom option max characters (reported by @oleksii-lisovyi) has been fixed in #26348 by @cedmudit in 2.4-develop branch
   Related commits:
     1. 16079d9
     2. 86dc12d
     3. a21b246
     4. 43f9e2b
     5. 7ba11b8
     6. 6c5fbcb
     7. f7819a6
  • Loading branch information
slavvka authored Mar 17, 2020
2 parents ba89f12 + a67e6bf commit 8eb9deb
Show file tree
Hide file tree
Showing 59 changed files with 1,584 additions and 469 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AddSimpleProductToCartActionGroup">
<actionGroup name="AddSimpleProductToCartActionGroup" deprecated="Avoid using super-ActionGroups. Use StorefrontOpenProductEntityPageActionGroup, StorefrontAddSimpleProductToCartActionGroup and StorefrontAssertProductAddedToCartResultMessageActionGroup">
<annotations>
<description>Navigates to the Storefront Product page. Then adds the Product to the Cart. Validates that the Success Message is present and correct.</description>
</annotations>
Expand Down
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="AdminChangeSeoUrlKeyForSubCategoryWithoutRedirectActionGroup" extends="ChangeSeoUrlKeyForSubCategoryActionGroup">
<annotations>
<description>Requires navigation to subcategory creation/edit. Updates the Search Engine Optimization with uncheck Redirect Checkbox .</description>
</annotations>
<arguments>
<argument name="value" type="string"/>
</arguments>

<uncheckOption selector="{{AdminCategorySEOSection.UrlKeyRedirectCheckbox}}" stepKey="uncheckRedirectCheckbox" after="enterURLKey"/>
</actionGroup>
</actionGroups>
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>
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>
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>
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>
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="StorefrontOpenProductEntityPageActionGroup">
<annotations>
<description>Opens Storefront Product page for the provided Product Entity</description>
</annotations>
<arguments>
<argument name="product" type="entity"/>
</arguments>

<amOnPage url="{{StorefrontProductPage.url(product.custom_attributes[url_key])}}" stepKey="goToProductPage"/>
<waitForPageLoad stepKey="waitForProductPageLoaded"/>
</actionGroup>
</actionGroups>
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>
16 changes: 16 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/CategoryData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@
<data key="is_active">false</data>
<data key="include_in_menu">false</data>
</entity>
<entity name="_defaultCategoryDifferentUrlStore" type="category">
<data key="name" unique="suffix">SimpleCategory</data>
<data key="name_lwr" unique="suffix">simplecategory</data>
<data key="is_active">true</data>
<data key="url_key_default_store" unique="suffix">default-simplecategory</data>
<data key="url_key_custom_store" unique="suffix">custom-simplecategory</data>
</entity>
<entity name="SimpleSubCategoryDifferentUrlStore" type="category">
<data key="name" unique="suffix">SimpleSubCategory</data>
<data key="name_lwr" unique="suffix">simplesubcategory</data>
<data key="is_active">true</data>
<data key="url_key_default_store" unique="suffix">default-simplesubcategory</data>
<data key="url_key_custom_store" unique="suffix">custom-simplesubcategory</data>
<data key="include_in_menu">true</data>
<var key="parent_id" entityType="category" entityKey="id" />
</entity>
<!-- Category from file "prepared-for-sample-data.csv"-->
<entity name="Gear" type="category">
<data key="name">Gear</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
<data key="attribute_code">short_description</data>
<data key="value" unique="suffix">API Product Short Description</data>
</entity>
<entity name="ApiProductSpecialPrice" type="custom_attribute">
<data key="attribute_code">special_price</data>
<data key="value">51.51</data>
</entity>
<entity name="ApiProductCost" type="custom_attribute">
<data key="attribute_code">cost</data>
<data key="value">50.05</data>
</entity>
<entity name="ApiProductNewsFromDate" type="custom_attribute">
<data key="attribute_code">news_from_date</data>
<data key="value">2018-05-17 00:00:00</data>
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
<data key="status">1</data>
<data key="quantity">0</data>
</entity>
<entity name="SimpleOutOfStockProductWithSpecialPriceAndCost" type="product" extends="SimpleOutOfStockProduct">
<requiredEntity type="custom_attribute_array">ApiProductSpecialPrice</requiredEntity>
<requiredEntity type="custom_attribute_array">ApiProductCost</requiredEntity>
</entity>
<entity name="SimpleProductInStockQuantityZero" type="product">
<data key="name" unique="suffix">SimpleProductInStockQuantityZero</data>
<data key="sku" unique="suffix">testSku</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<element name="firstProductRowEditButton" type="button" selector="table.data-grid tr.data-row td .action-menu-item:first-of-type"/>
<element name="productThumbnail" type="text" selector="table.data-grid tr:nth-child({{row}}) td.data-grid-thumbnail-cell > img" parameterized="true"/>
<element name="productThumbnailBySrc" type="text" selector="img.admin__control-thumbnail[src*='{{pattern}}']" parameterized="true"/>
<element name="productGridCell" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., '{{column}}')]/preceding-sibling::th) +1 ]" parameterized="true"/>
<element name="productGridCell" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[normalize-space(.)='{{column}}']/preceding-sibling::th) +1 ]" parameterized="true"/>
<element name="productGridHeaderCell" type="text" selector="//div[@data-role='grid-wrapper']//tr//th[contains(., '{{column}}')]" parameterized="true"/>
<element name="multicheckDropdown" type="button" selector="div[data-role='grid-wrapper'] th.data-grid-multicheck-cell button.action-multicheck-toggle"/>
<element name="multicheckOption" type="button" selector="//div[@data-role='grid-wrapper']//th[contains(@class, data-grid-multicheck-cell)]//li//span[text() = '{{label}}']" parameterized="true"/>
Expand Down
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>
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);
}
}
Loading

0 comments on commit 8eb9deb

Please sign in to comment.