Skip to content

Commit 13e54e1

Browse files
authored
Merge pull request #8381 from magento-l3/PR-07032023
L3 PR- 07032023
2 parents 41883fa + 0dca33c commit 13e54e1

File tree

21 files changed

+909
-193
lines changed

21 files changed

+909
-193
lines changed

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,13 @@ protected function prepareCatalogInventory(array $productIds)
640640
if ($stockItemRow['use_config_max_sale_qty']) {
641641
$stockItemRow['max_sale_qty'] = $this->stockConfiguration->getMaxSaleQty();
642642
}
643-
644643
if ($stockItemRow['use_config_min_sale_qty']) {
645644
$stockItemRow['min_sale_qty'] = $this->stockConfiguration->getMinSaleQty();
646645
}
646+
if ($stockItemRow['use_config_manage_stock']) {
647+
$stockItemRow['manage_stock'] = $this->stockConfiguration->getManageStock();
648+
}
649+
647650
$stockItemRows[$productId] = $stockItemRow;
648651
}
649652
return $stockItemRows;

app/code/Magento/Customer/Observer/Visitor/InitByRequestObserver.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,44 @@
66

77
namespace Magento\Customer\Observer\Visitor;
88

9+
use Magento\Customer\Model\Visitor;
910
use Magento\Framework\Event\Observer;
11+
use Magento\Framework\Session\SessionManagerInterface;
1012

1113
/**
1214
* Visitor Observer
15+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1316
*/
1417
class InitByRequestObserver extends AbstractVisitorObserver
1518
{
1619
/**
17-
* initByRequest
20+
* @var SessionManagerInterface
21+
*/
22+
private $sessionManager;
23+
24+
/**
25+
* @param Visitor $visitor
26+
* @param SessionManagerInterface $sessionManager
27+
*/
28+
public function __construct(
29+
Visitor $visitor,
30+
SessionManagerInterface $sessionManager
31+
) {
32+
parent::__construct($visitor);
33+
$this->sessionManager = $sessionManager;
34+
}
35+
36+
/**
37+
* Init visitor by request
1838
*
1939
* @param Observer $observer
2040
* @return void
2141
*/
2242
public function execute(Observer $observer)
2343
{
44+
if ($observer->getRequest()->getFullActionName() === 'customer_account_loginPost') {
45+
$this->sessionManager->setVisitorData(['do_customer_login' => true]);
46+
}
2447
$this->visitor->initByRequest($observer);
2548
}
2649
}

app/code/Magento/NewRelicReporting/Model/Apm/Deployments.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Laminas\Http\Request;
1010
use Magento\Framework\HTTP\LaminasClient;
1111
use Magento\Framework\HTTP\LaminasClientFactory;
12+
use Magento\Framework\Serialize\SerializerInterface;
1213
use Magento\NewRelicReporting\Model\Config;
1314
use Psr\Log\LoggerInterface;
1415

@@ -37,21 +38,29 @@ class Deployments
3738
*/
3839
protected $clientFactory;
3940

41+
/**
42+
* @var SerializerInterface
43+
*/
44+
private $serializer;
45+
4046
/**
4147
* Constructor
4248
*
4349
* @param Config $config
4450
* @param LoggerInterface $logger
4551
* @param LaminasClientFactory $clientFactory
52+
* @param SerializerInterface $serializer
4653
*/
4754
public function __construct(
4855
Config $config,
4956
LoggerInterface $logger,
50-
LaminasClientFactory $clientFactory
57+
LaminasClientFactory $clientFactory,
58+
SerializerInterface $serializer
5159
) {
5260
$this->config = $config;
5361
$this->logger = $logger;
5462
$this->clientFactory = $clientFactory;
63+
$this->serializer = $serializer;
5564
}
5665

5766
/**
@@ -97,8 +106,7 @@ public function setDeployment($description, $change = false, $user = false, $rev
97106
'revision' => $revision
98107
]
99108
];
100-
101-
$client->setParameterPost($params);
109+
$client->setRawBody($this->serializer->serialize($params));
102110

103111
try {
104112
$response = $client->send();

app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Laminas\Http\Response;
1313
use Magento\Framework\HTTP\LaminasClient;
1414
use Magento\Framework\HTTP\LaminasClientFactory;
15+
use Magento\Framework\Serialize\SerializerInterface;
1516
use Magento\NewRelicReporting\Model\Apm\Deployments;
1617
use Magento\NewRelicReporting\Model\Config;
1718
use PHPUnit\Framework\MockObject\MockObject;
@@ -45,31 +46,24 @@ class DeploymentsTest extends TestCase
4546
*/
4647
protected $loggerMock;
4748

49+
/**
50+
* @var SerializerInterface|MockObject
51+
*/
52+
private $serializerMock;
53+
4854
protected function setUp(): void
4955
{
50-
$this->httpClientFactoryMock = $this->getMockBuilder(LaminasClientFactory::class)
51-
->setMethods(['create'])
52-
->disableOriginalConstructor()
53-
->getMock();
54-
55-
$this->httpClientMock = $this->getMockBuilder(LaminasClient::class)
56-
->setMethods(['send', 'setUri', 'setMethod', 'setHeaders', 'setParameterPost'])
57-
->disableOriginalConstructor()
58-
->getMock();
59-
60-
$this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
61-
->disableOriginalConstructor()
62-
->getMockForAbstractClass();
63-
64-
$this->configMock = $this->getMockBuilder(Config::class)
65-
->setMethods(['getNewRelicApiUrl', 'getNewRelicApiKey', 'getNewRelicAppId'])
66-
->disableOriginalConstructor()
67-
->getMock();
56+
$this->httpClientFactoryMock = $this->createMock(LaminasClientFactory::class);
57+
$this->httpClientMock = $this->createMock(LaminasClient::class);
58+
$this->loggerMock = $this->createMock(LoggerInterface::class);
59+
$this->configMock = $this->createMock(Config::class);
60+
$this->serializerMock = $this->createMock(SerializerInterface::class);
6861

6962
$this->model = new Deployments(
7063
$this->configMock,
7164
$this->loggerMock,
72-
$this->httpClientFactoryMock
65+
$this->httpClientFactoryMock,
66+
$this->serializerMock
7367
);
7468
}
7569

@@ -97,9 +91,13 @@ public function testSetDeploymentRequestOk()
9791
->with($data['headers'])
9892
->willReturnSelf();
9993

100-
$this->httpClientMock->expects($this->once())
101-
->method('setParameterPost')
94+
$this->serializerMock->expects($this->once())
95+
->method('serialize')
10296
->with($data['params'])
97+
->willReturn(json_encode($data['params']));
98+
$this->httpClientMock->expects($this->once())
99+
->method('setRawBody')
100+
->with(json_encode($data['params']))
103101
->willReturnSelf();
104102

105103
$this->configMock->expects($this->once())
@@ -163,9 +161,13 @@ public function testSetDeploymentBadStatus()
163161
->with($data['headers'])
164162
->willReturnSelf();
165163

166-
$this->httpClientMock->expects($this->once())
167-
->method('setParameterPost')
164+
$this->serializerMock->expects($this->once())
165+
->method('serialize')
168166
->with($data['params'])
167+
->willReturn(json_encode($data['params']));
168+
$this->httpClientMock->expects($this->once())
169+
->method('setRawBody')
170+
->with(json_encode($data['params']))
169171
->willReturnSelf();
170172

171173
$this->configMock->expects($this->once())
@@ -225,9 +227,13 @@ public function testSetDeploymentRequestFail()
225227
->with($data['headers'])
226228
->willReturnSelf();
227229

228-
$this->httpClientMock->expects($this->once())
229-
->method('setParameterPost')
230+
$this->serializerMock->expects($this->once())
231+
->method('serialize')
230232
->with($data['params'])
233+
->willReturn(json_encode($data['params']));
234+
$this->httpClientMock->expects($this->once())
235+
->method('setRawBody')
236+
->with(json_encode($data['params']))
231237
->willReturnSelf();
232238

233239
$this->configMock->expects($this->once())

app/code/Magento/NewRelicReporting/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,9 @@
5353
</argument>
5454
</arguments>
5555
</type>
56+
<type name="Magento\NewRelicReporting\Model\Apm\Deployments">
57+
<arguments>
58+
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Json</argument>
59+
</arguments>
60+
</type>
5661
</config>

app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
class Discounts implements ResolverInterface
2020
{
21+
public const TYPE_SHIPPING = "SHIPPING";
22+
public const TYPE_ITEM = "ITEM";
2123
/**
2224
* @inheritdoc
2325
*/
@@ -41,21 +43,22 @@ private function getDiscountValues(Quote $quote)
4143
{
4244
$discountValues=[];
4345
$address = $quote->getShippingAddress();
44-
$totals = $address->getTotals();
45-
if ($totals && is_array($totals)) {
46-
foreach ($totals as $total) {
47-
if (stripos($total->getCode(), 'total') === false && $total->getValue() < 0.00) {
48-
$discount = [];
49-
$amount = [];
50-
$discount['label'] = $total->getTitle() ?: __('Discount');
51-
$amount['value'] = $total->getValue() * -1;
52-
$amount['currency'] = $quote->getQuoteCurrencyCode();
53-
$discount['amount'] = $amount;
54-
$discountValues[] = $discount;
55-
}
46+
$totalDiscounts = $address->getExtensionAttributes()->getDiscounts();
47+
48+
if ($totalDiscounts && is_array($totalDiscounts)) {
49+
foreach ($totalDiscounts as $value) {
50+
$discount = [];
51+
$amount = [];
52+
$discount['label'] = $value->getRuleLabel() ?: __('Discount');
53+
/* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discountData */
54+
$discountData = $value->getDiscountData();
55+
$discount['applied_to'] = $discountData->getAppliedTo();
56+
$amount['value'] = $discountData->getAmount();
57+
$amount['currency'] = $quote->getQuoteCurrencyCode();
58+
$discount['amount'] = $amount;
59+
$discountValues[] = $discount;
5660
}
57-
return $discountValues;
5861
}
59-
return null;
62+
return $discountValues ?: null;
6063
}
6164
}

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,17 @@ enum CartItemErrorType {
359359
ITEM_INCREMENTS
360360
}
361361

362-
type Discount @doc(description:"Defines an individual discount. A discount can be applied to the cart as a whole or to an item.") {
362+
type Discount @doc(description:"Defines an individual discount. A discount can be applied to the cart as a whole or to an item, shipping.") {
363363
amount: Money! @doc(description:"The amount of the discount.")
364+
applied_to: CartDiscountType! @doc(description:"The type of the entity the discount is applied to.")
364365
label: String! @doc(description:"A description of the discount.")
365366
}
366367

368+
enum CartDiscountType {
369+
ITEM
370+
SHIPPING
371+
}
372+
367373
type CartItemPrices @doc(description: "Contains details about the price of the item, including taxes and discounts.") {
368374
price: Money! @doc(description: "The price of the item before any discounts were applied. The price that might include tax, depending on the configured display settings for cart.")
369375
price_including_tax: Money! @doc(description: "The price of the item before any discounts were applied. The price that might include tax, depending on the configured display settings for cart.")

0 commit comments

Comments
 (0)