Skip to content

Commit d3ff603

Browse files
sidolovRizwan Khan
authored andcommitted
Merge pull request #8863 from magento-gl/spartans_pr_29032024_AC-11661
[Spartans] Bugfix Delivery
2 parents b645958 + d4f64e8 commit d3ff603

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

app/code/Magento/Config/Console/Command/ConfigShowCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private function outputResult(OutputInterface $output, $configValue, $configPath
238238
{
239239
if (!is_array($configValue)) {
240240
$value = $this->valueProcessor->process($this->scope, $this->scopeCode, $configValue, $configPath);
241-
$output->writeln($this->inputPath === $configPath ? $value : sprintf("%s - %s", $configPath, $value));
241+
$output->writeln($this->inputPath === $configPath ? [$value] : sprintf("%s - %s", $configPath, $value));
242242
} elseif (is_array($configValue)) {
243243
foreach ($configValue as $name => $value) {
244244
$childPath = empty($configPath) ? $name : ($configPath . '/' . $name);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Quote\Plugin;
10+
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Framework\Webapi\Rest\Request as RestRequest;
13+
use Magento\Quote\Api\CartRepositoryInterface;
14+
use Magento\Quote\Api\Data\CartInterface;
15+
use Magento\Sales\Api\OrderRepositoryInterface;
16+
17+
/**
18+
* Validate order id from request param
19+
*/
20+
class ValidateQuoteOrigOrder
21+
{
22+
/**
23+
* @var OrderRepositoryInterface|null
24+
*/
25+
private $orderRepository;
26+
27+
/**
28+
* @var RestRequest $request
29+
*/
30+
private $request;
31+
32+
/**
33+
* @param RestRequest $request
34+
* @param OrderRepositoryInterface $orderRepository
35+
*/
36+
public function __construct(RestRequest $request, OrderRepositoryInterface $orderRepository)
37+
{
38+
$this->request = $request;
39+
$this->orderRepository = $orderRepository;
40+
}
41+
42+
/**
43+
* Validate the user authorization to order
44+
*
45+
* @param CartRepositoryInterface $cartRepository
46+
* @param CartInterface $quote
47+
* @return void
48+
* @throws NoSuchEntityException
49+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
50+
*/
51+
public function beforeSave(
52+
CartRepositoryInterface $cartRepository,
53+
CartInterface $quote
54+
): void {
55+
$params = $this->request->getBodyParams();
56+
if (!empty($params) && isset($params['quote']['orig_order_id'])) {
57+
$orderId = $params['quote']['orig_order_id'];
58+
try {
59+
$order = $this->orderRepository->get($orderId);
60+
$orderCustomer = (int)$order->getCustomerId();
61+
if ($quote->getCustomerId() !== $orderCustomer) {
62+
throw new NoSuchEntityException(__('Please check input parameters.'));
63+
}
64+
} catch (\Exception $e) {
65+
throw new NoSuchEntityException(__('Please check input parameters.'), $e);
66+
}
67+
}
68+
}
69+
}

app/code/Magento/Quote/etc/webapi_rest/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@
2222
<type name="Magento\Webapi\Controller\Rest\ParamsOverrider">
2323
<plugin name="validateQuoteData" type="Magento\Quote\Plugin\Webapi\Controller\Rest\ValidateQuoteData" sortOrder="1" disabled="false" />
2424
</type>
25+
<type name="Magento\Quote\Api\CartRepositoryInterface">
26+
<plugin name="quoteValidateOrderId" type="Magento\Quote\Plugin\ValidateQuoteOrigOrder"/>
27+
</type>
2528
</config>

0 commit comments

Comments
 (0)