Skip to content

Commit f60cda3

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into MC-25022
2 parents f1bcf12 + cde4f67 commit f60cda3

File tree

36 files changed

+1228
-332
lines changed

36 files changed

+1228
-332
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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="AdminSetStoreInformationConfigurationActionGroup">
12+
<annotations>
13+
<description>Set Store Information configurations</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="storeName" type="string" defaultValue="{{AdminGeneralSetStoreNameConfigData.value}}"/>
17+
<argument name="storeHoursOfOperation" type="string" defaultValue="{{AdminGeneralSetStoreHoursConfigData.value}}"/>
18+
<argument name="vatNumber" type="string" defaultValue="{{AdminGeneralSetVatNumberConfigData.value}}"/>
19+
<argument name="telephone" type="string" defaultValue="{{US_Address_TX.telephone}}"/>
20+
<argument name="country" type="string" defaultValue="{{US_Address_TX.country_id}}"/>
21+
<argument name="state" type="string" defaultValue="{{US_Address_TX.state}}"/>
22+
<argument name="city" type="string" defaultValue="{{US_Address_TX.city}}"/>
23+
<argument name="postcode" type="string" defaultValue="{{US_Address_TX.postcode}}"/>
24+
<argument name="street" type="string" defaultValue="{{US_Address_TX.street[0]}}"/>
25+
</arguments>
26+
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} '{{storeName}}'" stepKey="setStoreInformationName"/>
27+
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} '{{telephone}}'" stepKey="setStoreInformationPhone"/>
28+
<magentoCLI command="config:set {{AdminGeneralSetStoreHoursConfigData.path}} '{{storeHoursOfOperation}}'" stepKey="setStoreHoursInformation"/>
29+
<magentoCLI command="config:set {{AdminGeneralSetCountryConfigData.path}} '{{country}}'" stepKey="setStoreInformationCountry"/>
30+
<magentoCLI command="config:set {{AdminGeneralSetStateConfigData.path}} '{{state}}'" stepKey="setStoreInformationState"/>
31+
<magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} '{{city}}'" stepKey="setStoreInformationCity"/>
32+
<magentoCLI command="config:set {{AdminGeneralSetPostcodeConfigData.path}} '{{postcode}}'" stepKey="setStoreInformationPostcode"/>
33+
<magentoCLI command="config:set {{AdminGeneralSetStreetAddressConfigData.path}} '{{street}}'" stepKey="setStoreInformationStreetAddress"/>
34+
<magentoCLI command="config:set {{AdminGeneralSetVatNumberConfigData.path}} '{{vatNumber}}'" stepKey="setStoreInformationVatNumber"/>
35+
</actionGroup>
36+
</actionGroups>

app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@
3030
<entity name="AdminGeneralSetStreetAddress2ConfigData">
3131
<data key="path">general/store_information/street_line2</data>
3232
</entity>
33+
<entity name="AdminGeneralSetStateConfigData">
34+
<data key="path">general/store_information/region_id</data>
35+
</entity>
36+
<entity name="AdminGeneralSetStoreHoursConfigData">
37+
<data key="path">general/store_information/hours</data>
38+
<data key="value">8AM-8PM</data>
39+
</entity>
3340
</entities>
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+
}

0 commit comments

Comments
 (0)