Skip to content

Commit e731518

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MC-31497
2 parents e56c798 + 852af4e commit e731518

File tree

118 files changed

+5132
-766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+5132
-766
lines changed

app/code/Magento/Backend/Block/Store/Switcher.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ public function getCurrentWebsiteName()
473473
return $website->getName();
474474
}
475475
}
476+
477+
return '';
476478
}
477479

478480
/**
@@ -489,6 +491,8 @@ public function getCurrentStoreGroupName()
489491
return $group->getName();
490492
}
491493
}
494+
495+
return '';
492496
}
493497

494498
/**
@@ -505,6 +509,8 @@ public function getCurrentStoreName()
505509
return $store->getName();
506510
}
507511
}
512+
513+
return '';
508514
}
509515

510516
/**
@@ -590,7 +596,7 @@ public function getHintHtml()
590596
class="admin__field-tooltip-action action-help"><span>%s</span></a></span></div>';
591597
$title = $this->escapeHtmlAttr(__('What is this?'));
592598
$span= $this->escapeHtml(__('What is this?'));
593-
sprintf($html, $this->escapeUrl($url), $title, $span);
599+
$html = sprintf($html, $this->escapeUrl($url), $title, $span);
594600
}
595601
return $html;
596602
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model\Product\Webapi;
9+
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Framework\Webapi\Request;
12+
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface;
13+
14+
/**
15+
* Class for checking empty array and remove it from the output result
16+
*/
17+
class ProductOutputProcessor
18+
{
19+
/**
20+
* @var Request
21+
*/
22+
private $request;
23+
24+
/**
25+
* @var DeserializerInterface
26+
*/
27+
private $deserializer;
28+
29+
/**
30+
* @param Request $request
31+
* @param DeserializerInterface $deserializer
32+
*/
33+
public function __construct(
34+
Request $request,
35+
DeserializerInterface $deserializer
36+
) {
37+
$this->request = $request;
38+
$this->deserializer = $deserializer;
39+
}
40+
41+
/**
42+
* Removing attribute from the result array if its null or empty
43+
*
44+
* @param ProductInterface $product
45+
* @param array $result
46+
* @return array
47+
*/
48+
public function execute(
49+
ProductInterface $product,
50+
array $result
51+
): array {
52+
$requestContent = $this->request->getContent() ?? [];
53+
if (empty($requestContent)) {
54+
return $result;
55+
}
56+
$requestContentDetails = (array)$this->deserializer->deserialize($requestContent);
57+
$requestProductList = $this->extractProductList($requestContentDetails);
58+
59+
$requestProductList = array_filter(
60+
$requestProductList,
61+
function ($requestProduct) use ($product) {
62+
return isset($requestProduct['sku']) && $requestProduct['sku'] === $product->getSku();
63+
}
64+
);
65+
66+
if (empty($requestProductList)) {
67+
return $result;
68+
}
69+
70+
$requestProduct = current($requestProductList);
71+
72+
if (empty($product->getTierPrices()) && !array_key_exists('tier_prices', $requestProduct)) {
73+
unset($result['tier_prices']);
74+
}
75+
76+
if (empty($product->getProductLinks()) && !array_key_exists('product_links', $requestProduct)) {
77+
unset($result['product_links']);
78+
}
79+
80+
return $result;
81+
}
82+
83+
/**
84+
* Extract product list from the request content details
85+
*
86+
* @param array $contentDetails
87+
* @return array
88+
*/
89+
private function extractProductList(array $contentDetails): array
90+
{
91+
$productList = [];
92+
$arrayIterator = new \RecursiveArrayIterator($contentDetails);
93+
$iterator = new \RecursiveIteratorIterator($arrayIterator, \RecursiveIteratorIterator::SELF_FIRST);
94+
foreach ($iterator as $iteratorKey => $iteratorValue) {
95+
if ($iteratorKey === 'product') {
96+
array_push($productList, $iteratorValue);
97+
}
98+
}
99+
return $productList;
100+
}
101+
}

app/code/Magento/Catalog/Model/Template/Filter.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
/**
1616
* Work with catalog(store, website) urls
17-
*
18-
* @package Magento\Catalog\Model\Template
1917
*/
2018
class Filter extends \Magento\Framework\Filter\Template
2119
{
@@ -30,6 +28,7 @@ class Filter extends \Magento\Framework\Filter\Template
3028
* Whether to allow SID in store directive: NO
3129
*
3230
* @var bool
31+
* @deprecated SID query parameter is not used in URLs anymore.
3332
*/
3433
protected $_useSessionInUrl = false;
3534

@@ -81,10 +80,14 @@ public function setUseAbsoluteLinks($flag)
8180
*
8281
* @param bool $flag
8382
* @return $this
83+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
84+
* @deprecated SID query parameter is not used in URLs anymore.
8485
*/
8586
public function setUseSessionInUrl($flag)
8687
{
87-
$this->_useSessionInUrl = $flag;
88+
// phpcs:disable Magento2.Functions.DiscouragedFunction
89+
trigger_error('Session ID is not used as URL parameter anymore.', E_USER_DEPRECATED);
90+
8891
return $this;
8992
}
9093

@@ -126,6 +129,7 @@ public function viewDirective($construction)
126129
*/
127130
public function mediaDirective($construction)
128131
{
132+
// phpcs:disable Magento2.Functions.DiscouragedFunction
129133
$params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES));
130134
return $this->_storeManager->getStore()
131135
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $params['url'];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminSetUseInSearchValueForProductAttributeActionGroup">
11+
<annotations>
12+
<description>Set 'Use In Search' value for product attribute</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="useInSearchValue" type="string" defaultValue="Yes"/>
16+
</arguments>
17+
18+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
19+
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/>
20+
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.UseInSearch}}" stepKey="waitForUseInSearchElementVisible"/>
21+
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInSearch}}" userInput="{{useInSearchValue}}" stepKey="setUseInSearchValue"/>
22+
</actionGroup>
23+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
-->
7+
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductControlsAreNotVisibleWithoutHoverActionGroup">
11+
<annotations>
12+
<description>Validate that the Product Controls Are Not Visible On Category Page Without Hover on Product</description>
13+
</annotations>
14+
15+
<dontSeeElement selector="{{StorefrontCategoryMainSection.addToCartButtonProductInfoHover}}" stepKey="assertAddToCartButtonElementIsNotVisible"/>
16+
<dontSeeElement selector="{{StorefrontCategoryMainSection.addToWishListIconProductInfoHover}}" stepKey="assertAddToWishListIconIsNotVisible"/>
17+
<dontSeeElement selector="{{StorefrontCategoryMainSection.addToCompareIconProductInfoHover}}" stepKey="assertAddToCompareIconIsNotVisible"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
-->
7+
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductControlsAreVisibleOnHoverActionGroup">
11+
<annotations>
12+
<description>Validate that the Product Controls Are Visible on Category Page on Hover on Product</description>
13+
</annotations>
14+
15+
<seeElement selector="{{StorefrontCategoryMainSection.addToCartButtonProductInfoHover}}" stepKey="assertAddToCartButtonElementIsVisible"/>
16+
<seeElement selector="{{StorefrontCategoryMainSection.addToWishListIconProductInfoHover}}" stepKey="assertAddToWishListIconIsVisible"/>
17+
<seeElement selector="{{StorefrontCategoryMainSection.addToCompareIconProductInfoHover}}" stepKey="assertAddToCompareIconIsVisible"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontProductIsPresentOnCategoryPageActionGroup">
12+
<annotations>
13+
<description>Validate that the provided Product is present and has correct name on a Category page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="productName" type="string" defaultValue="{{ApiSimpleOne.name}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontCategoryProductSection.ProductTitleByName(productName)}}" stepKey="assertProductName"/>
20+
</actionGroup>
21+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontProductPriceInCategoryPageActionGroup">
12+
<annotations>
13+
<description>Goes to Storefront Category page for the provided Category. Validates that the Product price is present and correct.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="categoryUrl" type="string" defaultValue="{{SimpleRootSubCategory.url_key}}"/>
17+
<argument name="productName" type="string" defaultValue="{{productWithHTMLEntityOne.name}}"/>
18+
<argument name="productPrice" type="string" defaultValue="{{productWithHTMLEntityOne.price}}"/>
19+
</arguments>
20+
21+
<amOnPage url="{{StorefrontCategoryPage.url(categoryUrl)}}" stepKey="navigateToCategoryPage"/>
22+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
23+
<see userInput="{{productPrice}}" selector="{{StorefrontCategoryProductSection.ProductPriceByName(productName)}}" stepKey="assertProductPrice"/>
24+
</actionGroup>
25+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontProductSpecialPriceInCategoryPageActionGroup" extends="AssertStorefrontProductPriceInCategoryPageActionGroup">
12+
<annotations>
13+
<description>Goes to Storefront Category page for the provided Category. Validates that the Product price and special price are correct.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="productSpecialPrice" type="string" defaultValue="{{updateVirtualProductSpecialPrice.special_price}}"/>
17+
</arguments>
18+
19+
<see userInput="{{productSpecialPrice}}" selector="{{StorefrontCategoryProductSection.ProductCatalogRuleSpecialPriceTitleByName(productName)}}" after="assertProductPrice" stepKey="assertProductSpecialPrice"/>
20+
</actionGroup>
21+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
<actionGroup name="AssertProductOnCategoryPageActionGroup" extends="StorefrontCheckCategorySimpleProduct">
8282
<annotations>
83-
<description>EXTENDS:StorefrontCheckCategorySimpleProduct. Removes 'AssertProductPrice', 'moveMouseOverProduct', 'AssertAddToCart'</description>
83+
<description>DEPRECATED Use AssertStorefrontProductIsPresentOnCategoryPageActionGroup. EXTENDS:StorefrontCheckCategorySimpleProduct. Removes 'AssertProductPrice', 'moveMouseOverProduct', 'AssertAddToCart'</description>
8484
</annotations>
8585
<remove keyForRemoval="AssertProductPrice"/>
8686
<remove keyForRemoval="moveMouseOverProduct"/>

0 commit comments

Comments
 (0)