Skip to content

Commit b092dd6

Browse files
authored
Merge pull request #7622 from magento-gl/Hammer_QaulityBacklog_GraphQL_05052022_v1
Hammer quality backlog graph ql 05052022 v1
2 parents fde5551 + 2954931 commit b092dd6

File tree

20 files changed

+714
-49
lines changed

20 files changed

+714
-49
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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\Bundle\Test\Fixture;
9+
10+
use Magento\Framework\DataObject;
11+
use Magento\Sales\Api\OrderRepositoryInterface;
12+
use Magento\TestFramework\Fixture\Api\DataMerger;
13+
use Magento\TestFramework\Fixture\Api\ServiceFactory;
14+
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
15+
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
16+
17+
class OrderItem implements RevertibleDataFixtureInterface
18+
{
19+
private const DEFAULT_DATA = [
20+
'items' => [
21+
['sku' => '%uniqid%']
22+
],
23+
'payment'=> [ 'method' => 'checkmo']
24+
];
25+
26+
/**
27+
* @var ServiceFactory
28+
*/
29+
private ServiceFactory $serviceFactory;
30+
31+
/**
32+
* @var ProcessorInterface
33+
*/
34+
private ProcessorInterface $dataProcessor;
35+
36+
/**
37+
* @var DataMerger
38+
*/
39+
private DataMerger $dataMerger;
40+
41+
/**
42+
* @param ServiceFactory $serviceFactory
43+
* @param ProcessorInterface $dataProcessor
44+
* @param DataMerger $dataMerger
45+
*/
46+
public function __construct(
47+
ServiceFactory $serviceFactory,
48+
ProcessorInterface $dataProcessor,
49+
DataMerger $dataMerger
50+
) {
51+
$this->serviceFactory = $serviceFactory;
52+
$this->dataProcessor = $dataProcessor;
53+
$this->dataMerger = $dataMerger;
54+
}
55+
56+
/**
57+
* @param array $data
58+
* @return DataObject|null
59+
*/
60+
public function apply(array $data = []): ?DataObject
61+
{
62+
$service = $this->serviceFactory->create(OrderRepositoryInterface::class, 'save');
63+
64+
return $service->execute(['entity' => $this->prepareData($data)]);
65+
}
66+
67+
/**
68+
* @inheritdoc
69+
*/
70+
public function revert(DataObject $data): void
71+
{
72+
$service = $this->serviceFactory->create(OrderRepositoryInterface::class, 'delete');
73+
74+
$service->execute(['entity' => $data]);
75+
}
76+
77+
/**
78+
* Prepare product data
79+
*
80+
* @param array $data
81+
* @return array
82+
*/
83+
private function prepareData(array $data): array
84+
{
85+
$data = $this->dataMerger->merge(self::DEFAULT_DATA, $data, false);
86+
87+
return $this->dataProcessor->process($this, $data);
88+
}
89+
}

app/code/Magento/CatalogInventory/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
"Magento\\CatalogInventory\\": ""
2929
}
3030
},
31-
"abandoned": "magento/inventory-composer-metapackage"
31+
"abandoned": "magento/inventory-metapackage"
3232
}

app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/Product/Price/Provider.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
namespace Magento\ConfigurableProductGraphQl\Model\Resolver\Product\Price;
99

10+
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
1011
use Magento\Catalog\Pricing\Price\FinalPrice;
1112
use Magento\Catalog\Pricing\Price\RegularPrice;
12-
use Magento\Framework\Pricing\Amount\AmountInterface;
13-
use Magento\Framework\Pricing\SaleableInterface;
1413
use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderInterface;
1514
use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface;
15+
use Magento\Framework\Pricing\Amount\AmountInterface;
16+
use Magento\Framework\Pricing\SaleableInterface;
1617

1718
/**
1819
* Provides product prices for configurable products
@@ -100,7 +101,7 @@ private function getMinimalPrice(SaleableInterface $product, string $code): Amou
100101
{
101102
if (!isset($this->minimalPrice[$code][$product->getId()])) {
102103
$minimumAmount = null;
103-
foreach ($this->optionsProvider->getProducts($product) as $variant) {
104+
foreach ($this->filterDisabledProducts($this->optionsProvider->getProducts($product)) as $variant) {
104105
$variantAmount = $variant->getPriceInfo()->getPrice($code)->getAmount();
105106
if (!$minimumAmount || ($variantAmount->getValue() < $minimumAmount->getValue())) {
106107
$minimumAmount = $variantAmount;
@@ -134,4 +135,17 @@ private function getMaximalPrice(SaleableInterface $product, string $code): Amou
134135

135136
return $this->maximalPrice[$code][$product->getId()];
136137
}
138+
139+
/**
140+
* Filter out disabled products
141+
*
142+
* @param array $products
143+
* @return array
144+
*/
145+
private function filterDisabledProducts(array $products): array
146+
{
147+
return array_filter($products, function ($product) {
148+
return (int)$product->getStatus() === ProductStatus::STATUS_ENABLED;
149+
});
150+
}
137151
}

app/code/Magento/LoginAsCustomerAdminUi/Block/Adminhtml/ConfirmationPopup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function getJsLayout()
8282

8383
$layout['components']['lac-confirmation-popup']['showStoreViewOptions'] = $showStoreViewOptions;
8484
$layout['components']['lac-confirmation-popup']['storeViewOptions'] = $showStoreViewOptions
85-
? $this->options->toOptionArray()
86-
: [];
85+
? (($this->_request->getParam('id') || $this->_request->getParam('order_id'))
86+
? $this->options->toOptionArray() : []) : [];
8787

8888
return $this->json->serialize($layout);
8989
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminLoginAsCustomerManualSelectionTest">
12+
<annotations>
13+
<features value="Login as Customer"/>
14+
<stories value="Select Store based on 'Store View To Login In' setting"/>
15+
<title
16+
value="Admin user directly login into customer account with store View To Login In = Manual Selection"/>
17+
<description
18+
value="Verify admin user can directly login into customer account to Default store view when Store View To Login In = Manual Selection"/>
19+
<severity value="AVERAGE"/>
20+
<group value="login_as_customer_admin_ui"/>
21+
</annotations>
22+
<before>
23+
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
24+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
25+
stepKey="enableLoginAsCustomer"/>
26+
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 1"
27+
stepKey="enableLoginAsCustomerManualChoose"/>
28+
<comment userInput="Adding the comment to replace 'cache:flush' command for preserving Backward Compatibility" stepKey="flushCacheBeforeTestRun"/>
29+
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
30+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createCustomStore">
31+
<argument name="website" value="{{_defaultWebsite.name}}"/>
32+
<argument name="storeGroupName" value="{{customStoreGroup.name}}"/>
33+
<argument name="storeGroupCode" value="{{customStoreGroup.code}}"/>
34+
</actionGroup>
35+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createFirstCustomStoreView">
36+
<argument name="StoreGroup" value="customStoreGroup"/>
37+
<argument name="customStore" value="customStoreEN"/>
38+
</actionGroup>
39+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createSecondCustomStoreView">
40+
<argument name="StoreGroup" value="customStoreGroup"/>
41+
<argument name="customStore" value="customStoreFR"/>
42+
</actionGroup>
43+
<magentoCron groups="index" stepKey="reindex"/>
44+
</before>
45+
<after>
46+
<actionGroup ref="DeleteCustomStoreActionGroup" stepKey="deleteCustomStore">
47+
<argument name="storeGroupName" value="customStoreGroup.name"/>
48+
</actionGroup>
49+
<magentoCron groups="index" stepKey="reindex"/>
50+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
51+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0"
52+
stepKey="disableLoginAsCustomer"/>
53+
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
54+
stepKey="enableLoginAsCustomerAutoDetection"/>
55+
<comment userInput="Adding the comment to replace 'cache:flush' command for preserving Backward Compatibility" stepKey="flushCacheAfterTestRun"/>
56+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
57+
</after>
58+
59+
<!-- Login as Customer from Customer page -->
60+
<actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageManualChooseActionGroup"
61+
stepKey="loginAsCustomerFromCustomerPage">
62+
<argument name="customerId" value="$$createCustomer.id$$"/>
63+
<argument name="storeName" value="{{customStoreGroup.name}}"/>
64+
</actionGroup>
65+
66+
<!-- Assert Customer logged on on custom store view -->
67+
<actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird">
68+
<argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/>
69+
<argument name="customerEmail" value="$$createCustomer.email$$"/>
70+
</actionGroup>
71+
<actionGroup ref="StorefrontAssertCustomerOnStoreViewActionGroup" stepKey="assertCustomStoreView">
72+
<argument name="storeViewName" value="{{customStoreEN.name}}"/>
73+
</actionGroup>
74+
75+
<!-- Log out Customer and close tab -->
76+
<actionGroup ref="StorefrontSignOutAndCloseTabActionGroup" stepKey="signOutAndCloseTab"/>
77+
</test>
78+
</tests>

app/code/Magento/SalesRule/Model/Converter/ToModel.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
*/
66
namespace Magento\SalesRule\Model\Converter;
77

8-
use Magento\SalesRule\Model\Data\Condition;
98
use Magento\SalesRule\Api\Data\RuleInterface;
9+
use Magento\SalesRule\Model\Data\Condition;
1010
use Magento\SalesRule\Model\Data\Rule as RuleDataModel;
1111
use Magento\SalesRule\Model\Rule;
1212

1313
class ToModel
1414
{
15+
public const DATE_TIME_FORMAT = 'Y-m-d\TH:i:s';
16+
1517
/**
1618
* @var \Magento\SalesRule\Model\RuleFactory
1719
*/
@@ -35,6 +37,8 @@ public function __construct(
3537
}
3638

3739
/**
40+
* Map conditions
41+
*
3842
* @param \Magento\SalesRule\Model\Rule $ruleModel
3943
* @param RuleDataModel $dataModel
4044
* @return $this
@@ -51,6 +55,8 @@ protected function mapConditions(\Magento\SalesRule\Model\Rule $ruleModel, RuleD
5155
}
5256

5357
/**
58+
* Map action conditions
59+
*
5460
* @param \Magento\SalesRule\Model\Rule $ruleModel
5561
* @param RuleDataModel $dataModel
5662
* @return $this
@@ -67,6 +73,8 @@ protected function mapActionConditions(\Magento\SalesRule\Model\Rule $ruleModel,
6773
}
6874

6975
/**
76+
* Map store labels
77+
*
7078
* @param Rule $ruleModel
7179
* @param RuleDataModel $dataModel
7280
* @return $this
@@ -86,12 +94,14 @@ protected function mapStoreLabels(Rule $ruleModel, RuleDataModel $dataModel)
8694
}
8795

8896
/**
97+
* Map coupon type
98+
*
8999
* @param Rule $ruleModel
90100
* @return $this
91101
*/
92102
protected function mapCouponType(Rule $ruleModel)
93103
{
94-
if ($ruleModel->getCouponType()) {
104+
if ($ruleModel->getCouponType() && !is_numeric($ruleModel->getCouponType())) {
95105
$mappedValue = '';
96106
switch ($ruleModel->getCouponType()) {
97107
case RuleInterface::COUPON_TYPE_NO_COUPON:
@@ -111,6 +121,8 @@ protected function mapCouponType(Rule $ruleModel)
111121
}
112122

113123
/**
124+
* Map fields
125+
*
114126
* @param \Magento\SalesRule\Model\Rule $ruleModel
115127
* @param RuleDataModel $dataModel
116128
* @return $this
@@ -153,6 +165,8 @@ public function dataModelToArray(Condition $condition, $key = 'conditions')
153165
}
154166

155167
/**
168+
* To Model
169+
*
156170
* @param RuleDataModel $dataModel
157171
* @return $this|Rule
158172
* @throws \Magento\Framework\Exception\NoSuchEntityException
@@ -184,6 +198,9 @@ public function toModel(RuleDataModel $dataModel)
184198
\Magento\SalesRule\Api\Data\RuleInterface::class
185199
);
186200

201+
$data = array_filter($data, function ($value) {
202+
return $value !== null;
203+
});
187204
$mergedData = array_merge($modelData, $data);
188205

189206
$validateResult = $ruleModel->validateData(new \Magento\Framework\DataObject($mergedData));
@@ -214,7 +231,7 @@ private function formattingDate($date)
214231
{
215232
if ($date) {
216233
$fromDate = new \DateTime($date);
217-
$date = $fromDate->format(\DateTime::ISO8601);
234+
$date = $fromDate->format(self::DATE_TIME_FORMAT);
218235
}
219236

220237
return $date;

app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToModelTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,24 @@ public function expectedDatesProvider()
294294
[
295295
'from_date' => '03/24/2016',
296296
'to_date' => '03/25/2016',
297-
'expected_from_date' => '2016-03-24T00:00:00-0700',
298-
'expected_to_date' => '2016-03-25T00:00:00-0700',
297+
'expected_from_date' => '2016-03-24T00:00:00',
298+
'expected_to_date' => '2016-03-25T00:00:00',
299299
]
300300
],
301301
'yyyy-mm-dd to yyyy-mm-dd' => [
302302
[
303303
'from_date' => '2016-03-24',
304304
'to_date' => '2016-03-25',
305-
'expected_from_date' => '2016-03-24T00:00:00-0700',
306-
'expected_to_date' => '2016-03-25T00:00:00-0700',
305+
'expected_from_date' => '2016-03-24T00:00:00',
306+
'expected_to_date' => '2016-03-25T00:00:00',
307307
]
308308
],
309309
'yymmdd to yyyy-mm-dd' => [
310310
[
311311
'from_date' => '20160324',
312312
'to_date' => '20160325',
313-
'expected_from_date' => '2016-03-24T00:00:00-0700',
314-
'expected_to_date' => '2016-03-25T00:00:00-0700',
313+
'expected_from_date' => '2016-03-24T00:00:00',
314+
'expected_to_date' => '2016-03-25T00:00:00',
315315
]
316316
],
317317
];

app/code/Magento/Tax/Model/ResourceModel/Calculation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class Calculation extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
1616
*/
1717
public const USA_COUNTRY_CODE = 'US';
1818

19+
public const PORTUGAL_COUNTRY_CODE = 'PT';
20+
1921
/**
2022
* @var array
2123
*/
@@ -342,7 +344,9 @@ protected function _getRates($request)
342344
$zipFrom = null;
343345
$zipTo = null;
344346
if (is_string($postcode) && preg_match('/^(.+)-(.+)$/', $postcode, $matches)) {
345-
if ($countryId == self::USA_COUNTRY_CODE && is_numeric($matches[2]) && strlen($matches[2]) == 4) {
347+
if ((self::USA_COUNTRY_CODE === $countryId && is_numeric($matches[2]) && 4 === strlen($matches[2])) ||
348+
(self::PORTUGAL_COUNTRY_CODE === $countryId && is_numeric($matches[2]) && 3 === strlen($matches[2]))
349+
) {
346350
$postcodeIsNumeric = true;
347351
$originalPostcode = $postcode;
348352
$postcode = $matches[1];

0 commit comments

Comments
 (0)