Skip to content

Commit 0cc9848

Browse files
committed
AC-13793::Replace lusitanian/oauth with alternate carlos-mg89/oauth
1 parent 3f12d15 commit 0cc9848

File tree

90 files changed

+3318
-423
lines changed

Some content is hidden

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

90 files changed

+3318
-423
lines changed

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Bundle\Pricing\Adjustment;
@@ -173,12 +173,9 @@ private function addMiniMaxPriceList(Product $bundleProduct, $selectionsCollecti
173173
*/
174174
private function addMaximumMultiSelectionPriceList(Product $bundleProduct, $selectionsCollection, $useRegularPrice)
175175
{
176-
$websiteId = null;
177-
if (!$this->catalogData->isPriceGlobal()) {
178-
$websiteId = (int)$this->storeManager->getStore()->getWebsiteId();
179-
if ($websiteId === 0) {
180-
$websiteId = $this->websiteRepository->getDefault()->getId();
181-
}
176+
$websiteId = (int)$this->storeManager->getStore()->getWebsiteId();
177+
if ($websiteId === 0) {
178+
$websiteId = $this->websiteRepository->getDefault()->getId();
182179
}
183180
$selectionsCollection->addPriceData(null, $websiteId);
184181

app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/DefaultSelectionPriceListProviderTest.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2022 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -189,7 +189,10 @@ public function testGetPriceList(): void
189189
$this->model->getPriceList($this->product, false, false);
190190
}
191191

192-
public function testGetPriceListForFixedPriceType(): void
192+
/**
193+
* @dataProvider dataProvider
194+
*/
195+
public function testGetPriceListForFixedPriceType($websiteId): void
193196
{
194197
$optionId = 1;
195198

@@ -218,13 +221,19 @@ public function testGetPriceListForFixedPriceType(): void
218221
->willReturn($this->store);
219222
$this->store->expects($this->once())
220223
->method('getWebsiteId')
221-
->willReturn(0);
222-
$this->websiteRepository->expects($this->once())
223-
->method('getDefault')
224-
->willReturn($this->website);
225-
$this->website->expects($this->once())
226-
->method('getId')
227-
->willReturn(1);
224+
->willReturn($websiteId);
225+
226+
if ($websiteId) {
227+
$this->websiteRepository->expects($this->never())
228+
->method('getDefault');
229+
} else {
230+
$this->websiteRepository->expects($this->once())
231+
->method('getDefault')
232+
->willReturn($this->website);
233+
$this->website->expects($this->once())
234+
->method('getId')
235+
->willReturn(1);
236+
}
228237
$this->selectionCollection->expects($this->once())
229238
->method('getIterator')
230239
->willReturn(new \ArrayIterator([]));
@@ -271,4 +280,12 @@ public function testGetPriceListWithSearchMin(): void
271280

272281
$this->model->getPriceList($this->product, true, false);
273282
}
283+
284+
public static function dataProvider()
285+
{
286+
return [
287+
'website provided' => [1],
288+
'website not provided' => [0]
289+
];
290+
}
274291
}

app/code/Magento/CatalogGraphQl/Model/PriceRangeDataProvider.php

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\CatalogGraphQl\Model;
99

10-
use Exception;
1110
use Magento\Catalog\Api\Data\ProductInterface;
1211
use Magento\Catalog\Model\Product;
1312
use Magento\CatalogGraphQl\Model\Resolver\Product\Price\Discount;
1413
use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool as PriceProviderPool;
1514
use Magento\Framework\Exception\LocalizedException;
16-
use Magento\Framework\GraphQl\Query\Resolver\Value;
1715
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1816
use Magento\Framework\Pricing\PriceCurrencyInterface;
1917
use Magento\Framework\Pricing\SaleableInterface;
@@ -27,6 +25,8 @@ class PriceRangeDataProvider
2725
{
2826
private const STORE_FILTER_CACHE_KEY = '_cache_instance_store_filter';
2927

28+
private const TYPE_DOWNLOADABLE = 'downloadable';
29+
3030
/**
3131
* @param PriceProviderPool $priceProviderPool
3232
* @param Discount $discount
@@ -45,18 +45,48 @@ public function __construct(
4545
* @param ContextInterface $context
4646
* @param ResolveInfo $info
4747
* @param array $value
48-
* @throws Exception
49-
* @return mixed|Value
48+
* @return array
49+
* @throws LocalizedException
5050
*/
5151
public function prepare(ContextInterface $context, ResolveInfo $info, array $value): array
52+
{
53+
$store = $context->getExtensionAttributes()->getStore();
54+
$product = $this->getProduct($value, $context, $store);
55+
56+
$requestedFields = $info->getFieldSelection(10);
57+
$returnArray = [];
58+
59+
$returnArray['minimum_price'] = ($requestedFields['minimum_price'] ?? 0) ? ($this->canShowPrice($product) ?
60+
$this->getMinimumProductPrice($product, $store) : $this->formatEmptyResult()) : $this->formatEmptyResult();
61+
$returnArray['maximum_price'] = ($requestedFields['maximum_price'] ?? 0) ? ($this->canShowPrice($product) ?
62+
$this->getMaximumProductPrice($product, $store) : $this->formatEmptyResult()) : $this->formatEmptyResult();
63+
64+
if ($product->getTypeId() === self::TYPE_DOWNLOADABLE &&
65+
$product->getData('links_purchased_separately')) {
66+
$downloadableLinkPrice = (float)$this->getDownloadableLinkPrice($product);
67+
if ($downloadableLinkPrice > 0) {
68+
$returnArray['maximum_price']['regular_price']['value'] += $downloadableLinkPrice;
69+
$returnArray['maximum_price']['final_price']['value'] += $downloadableLinkPrice;
70+
}
71+
}
72+
73+
return $returnArray;
74+
}
75+
76+
/**
77+
* Validate and return product
78+
*
79+
* @param array $value
80+
* @param ContextInterface $context
81+
* @param StoreInterface $store
82+
* @return Product
83+
* @throws LocalizedException
84+
*/
85+
private function getProduct(array $value, ContextInterface $context, StoreInterface $store): Product
5286
{
5387
if (!isset($value['model'])) {
5488
throw new LocalizedException(__('"model" value should be specified'));
5589
}
56-
/** @var StoreInterface $store */
57-
$store = $context->getExtensionAttributes()->getStore();
58-
59-
/** @var Product $product */
6090
$product = $value['model'];
6191
$product->unsetData('minimal_price');
6292
// add store filter for the product
@@ -69,15 +99,28 @@ public function prepare(ContextInterface $context, ResolveInfo $info, array $val
6999
}
70100
}
71101

72-
$requestedFields = $info->getFieldSelection(10);
73-
$returnArray = [];
102+
return $product;
103+
}
74104

75-
$returnArray['minimum_price'] = ($requestedFields['minimum_price'] ?? 0) ? ($this->canShowPrice($product) ?
76-
$this->getMinimumProductPrice($product, $store) : $this->formatEmptyResult()) : $this->formatEmptyResult();
77-
$returnArray['maximum_price'] = ($requestedFields['maximum_price'] ?? 0) ? ($this->canShowPrice($product) ?
78-
$this->getMaximumProductPrice($product, $store) : $this->formatEmptyResult()) : $this->formatEmptyResult();
105+
/**
106+
* Get the downloadable link price
107+
*
108+
* @param Product $product
109+
* @return float
110+
*/
111+
private function getDownloadableLinkPrice(Product $product): float
112+
{
113+
$downloadableLinks = $product->getTypeInstance()->getLinks($product);
114+
if (empty($downloadableLinks)) {
115+
return 0.0;
116+
}
79117

80-
return $returnArray;
118+
$price = 0.0;
119+
foreach ($downloadableLinks as $link) {
120+
$price += (float)$link->getPrice();
121+
}
122+
123+
return $price;
81124
}
82125

83126
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Product;
9+
10+
use Magento\Framework\Escaper;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\GraphQl\Config\Element\Field;
13+
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
16+
class ProductName implements ResolverInterface
17+
{
18+
/**
19+
* ProductName constructor
20+
*
21+
* @param Escaper $escaper
22+
*/
23+
public function __construct(
24+
private readonly Escaper $escaper
25+
) {
26+
}
27+
28+
/**
29+
* @inheritdoc
30+
*
31+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
32+
*/
33+
public function resolve(
34+
Field $field,
35+
$context,
36+
ResolveInfo $info,
37+
array $value = null,
38+
array $args = null
39+
): string {
40+
if (!isset($value['model'])) {
41+
throw new LocalizedException(__('"model" value should be specified'));
42+
}
43+
44+
// Product name allowed with special characters
45+
return str_replace(
46+
"&apos;",
47+
"'",
48+
str_replace("&amp;", "&", $this->escaper->escapeUrl($value['model']->getName()))
49+
);
50+
}
51+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Copyright © Magento, Inc. All rights reserved.
2-
# See COPYING.txt for license details.
1+
# Copyright 2025 Adobe
2+
# All Rights Reserved.
33

44
type Query {
55
products (
@@ -93,7 +93,7 @@ interface ProductLinksInterface @typeResolver(class: "Magento\\CatalogGraphQl\\M
9393
interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description: "Contains fields that are common to all types of products.") {
9494
id: Int @deprecated(reason: "Use the `uid` field instead.") @doc(description: "The ID number assigned to the product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\EntityIdToId")
9595
uid: ID! @doc(description: "The unique ID for a `ProductInterface` object.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\EntityIdToUid")
96-
name: String @doc(description: "The product name. Customers use this name to identify the product.")
96+
name: String @doc(description: "The product name. Customers use this name to identify the product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductName")
9797
sku: String @doc(description: "A number or code assigned to a product to identify the product, options, price, and manufacturer.")
9898
description: ComplexTextValue @doc(description: "Detailed information about the product. The value can include simple HTML tags.") @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductComplexTextAttribute")
9999
short_description: ComplexTextValue @doc(description: "A short description of the product. Its use depends on the theme.") @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductComplexTextAttribute")
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogInventoryGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\CatalogInventoryGraphQl\Model\StockItemService;
14+
15+
/**
16+
* Resolver for ProductInterface max quantity
17+
* Returns the available stock max quantity
18+
*/
19+
class MaxSaleQtyResolver implements ResolverInterface
20+
{
21+
/**
22+
* @var StockItemService
23+
*/
24+
private $stockItemService;
25+
26+
/**
27+
* @param StockItemService $stockItemService
28+
*/
29+
public function __construct(
30+
StockItemService $stockItemService
31+
) {
32+
$this->stockItemService = $stockItemService;
33+
}
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
public function resolve(
39+
Field $field,
40+
$context,
41+
ResolveInfo $info,
42+
?array $value = null,
43+
?array $args = null
44+
) {
45+
$stockItem = $this->stockItemService->getStockItem($value['model']);
46+
return $stockItem?->getMaxSaleQty();
47+
}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogInventoryGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\CatalogInventoryGraphQl\Model\StockItemService;
14+
15+
/**
16+
* Resolver for ProductInterface min quantity
17+
* Returns the available stock min quantity
18+
*/
19+
class MinSaleQtyResolver implements ResolverInterface
20+
{
21+
/**
22+
* @var StockItemService
23+
*/
24+
private $stockItemService;
25+
26+
/**
27+
* @param StockItemService $stockItemService
28+
*/
29+
public function __construct(
30+
StockItemService $stockItemService
31+
) {
32+
$this->stockItemService = $stockItemService;
33+
}
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
public function resolve(
39+
Field $field,
40+
$context,
41+
ResolveInfo $info,
42+
?array $value = null,
43+
?array $args = null
44+
) {
45+
$stockItem = $this->stockItemService->getStockItem($value['model']);
46+
return $stockItem?->getMinSaleQty();
47+
}
48+
}

0 commit comments

Comments
 (0)