Skip to content

Commit cff6a6f

Browse files
Merge branch '2.4-develop' into dhl-mbstring-labels
2 parents f20cf58 + e00d2fc commit cff6a6f

File tree

164 files changed

+8673
-3254
lines changed

Some content is hidden

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

164 files changed

+8673
-3254
lines changed

app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
use Magento\Bundle\Helper\Catalog\Product\Configuration;
1111
use Magento\Catalog\Model\Product;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\GraphQl\Query\Uid;
1214
use Magento\Quote\Model\Quote\Item;
1315
use Magento\Framework\Pricing\Helper\Data;
1416
use Magento\Framework\Serialize\SerializerInterface;
@@ -18,6 +20,11 @@
1820
*/
1921
class BundleOptionDataProvider
2022
{
23+
/**
24+
* Option type name
25+
*/
26+
private const OPTION_TYPE = 'bundle';
27+
2128
/**
2229
* @var Data
2330
*/
@@ -33,19 +40,26 @@ class BundleOptionDataProvider
3340
*/
3441
private $configuration;
3542

43+
/** @var Uid */
44+
private $uidEncoder;
45+
3646
/**
3747
* @param Data $pricingHelper
3848
* @param SerializerInterface $serializer
3949
* @param Configuration $configuration
50+
* @param Uid|null $uidEncoder
4051
*/
4152
public function __construct(
4253
Data $pricingHelper,
4354
SerializerInterface $serializer,
44-
Configuration $configuration
55+
Configuration $configuration,
56+
Uid $uidEncoder = null
4557
) {
4658
$this->pricingHelper = $pricingHelper;
4759
$this->serializer = $serializer;
4860
$this->configuration = $configuration;
61+
$this->uidEncoder = $uidEncoder ?: ObjectManager::getInstance()
62+
->get(Uid::class);
4963
}
5064

5165
/**
@@ -103,6 +117,7 @@ private function buildBundleOptions(array $bundleOptions, Item $item): array
103117

104118
$options[] = [
105119
'id' => $bundleOption->getId(),
120+
'uid' => $this->uidEncoder->encode(self::OPTION_TYPE . '/' . $bundleOption->getId()),
106121
'label' => $bundleOption->getTitle(),
107122
'type' => $bundleOption->getType(),
108123
'values' => $this->buildBundleOptionValues($bundleOption->getSelections(), $item),
@@ -131,9 +146,15 @@ private function buildBundleOptionValues(array $selections, Item $item): array
131146
}
132147

133148
$selectionPrice = $this->configuration->getSelectionFinalPrice($item, $selection);
134-
149+
$optionDetails = [
150+
self::OPTION_TYPE,
151+
$selection->getData('option_id'),
152+
$selection->getData('selection_id'),
153+
(int) $selection->getData('selection_qty')
154+
];
135155
$values[] = [
136156
'id' => $selection->getSelectionId(),
157+
'uid' => $this->uidEncoder->encode(implode('/', $optionDetails)),
137158
'label' => $selection->getName(),
138159
'quantity' => $qty,
139160
'price' => $this->pricingHelper->currency($selectionPrice, false, false),

app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use Magento\Bundle\Model\Selection;
1111
use Magento\Bundle\Model\ResourceModel\Selection\CollectionFactory;
1212
use Magento\Bundle\Model\ResourceModel\Selection\Collection as LinkCollection;
13+
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\GraphQl\Query\EnumLookup;
15+
use Magento\Framework\GraphQl\Query\Uid;
1416

1517
/**
1618
* Collection to fetch link data at resolution time.
@@ -42,14 +44,23 @@ class Collection
4244
*/
4345
private $links = [];
4446

47+
/** @var Uid */
48+
private $uidEncoder;
49+
4550
/**
4651
* @param CollectionFactory $linkCollectionFactory
4752
* @param EnumLookup $enumLookup
53+
* @param Uid|null $uidEncoder
4854
*/
49-
public function __construct(CollectionFactory $linkCollectionFactory, EnumLookup $enumLookup)
50-
{
55+
public function __construct(
56+
CollectionFactory $linkCollectionFactory,
57+
EnumLookup $enumLookup,
58+
Uid $uidEncoder = null
59+
) {
5160
$this->linkCollectionFactory = $linkCollectionFactory;
5261
$this->enumLookup = $enumLookup;
62+
$this->uidEncoder = $uidEncoder ?: ObjectManager::getInstance()
63+
->get(Uid::class);
5364
}
5465

5566
/**
@@ -117,6 +128,7 @@ private function fetch() : array
117128
'price' => $link->getSelectionPriceValue(),
118129
'position' => $link->getPosition(),
119130
'id' => $link->getSelectionId(),
131+
'uid' => $this->uidEncoder->encode((string) $link->getSelectionId()),
120132
'qty' => (float)$link->getSelectionQty(),
121133
'quantity' => (float)$link->getSelectionQty(),
122134
'is_default' => (bool)$link->getIsDefault(),

app/code/Magento/BundleGraphQl/Model/Resolver/Options/BundleItemOptionUid.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1212
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1313
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Query\Uid;
1415
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1516

1617
/**
@@ -23,6 +24,17 @@ class BundleItemOptionUid implements ResolverInterface
2324
*/
2425
private const OPTION_TYPE = 'bundle';
2526

27+
/** @var Uid */
28+
private $uidEncoder;
29+
30+
/**
31+
* @param Uid $uidEncoder
32+
*/
33+
public function __construct(Uid $uidEncoder)
34+
{
35+
$this->uidEncoder = $uidEncoder;
36+
}
37+
2638
/**
2739
* Create a option uid for entered option in "<option-type>/<option-id>/<option-value-id>/<quantity>" format
2840
*
@@ -62,7 +74,6 @@ public function resolve(
6274

6375
$content = implode('/', $optionDetails);
6476

65-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
66-
return base64_encode($content);
77+
return $this->uidEncoder->encode($content);
6778
}
6879
}

app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
*/
66
declare(strict_types=1);
77

8-
98
namespace Magento\BundleGraphQl\Model\Resolver\Options;
109

1110
use Magento\Bundle\Model\OptionFactory;
1211
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\GraphQl\Query\Uid;
1314
use Magento\Store\Model\StoreManagerInterface;
1415

1516
/**
1617
* Collection to fetch bundle option data at resolution time.
1718
*/
1819
class Collection
1920
{
21+
/**
22+
* Option type name
23+
*/
24+
private const OPTION_TYPE = 'bundle';
25+
2026
/**
2127
* @var OptionFactory
2228
*/
@@ -42,19 +48,26 @@ class Collection
4248
*/
4349
private $optionMap = [];
4450

51+
/** @var Uid */
52+
private $uidEncoder;
53+
4554
/**
4655
* @param OptionFactory $bundleOptionFactory
4756
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
4857
* @param StoreManagerInterface $storeManager
58+
* @param Uid|null $uidEncoder
4959
*/
5060
public function __construct(
5161
OptionFactory $bundleOptionFactory,
5262
JoinProcessorInterface $extensionAttributesJoinProcessor,
53-
StoreManagerInterface $storeManager
63+
StoreManagerInterface $storeManager,
64+
Uid $uidEncoder = null
5465
) {
5566
$this->bundleOptionFactory = $bundleOptionFactory;
5667
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
5768
$this->storeManager = $storeManager;
69+
$this->uidEncoder = $uidEncoder ?: ObjectManager::getInstance()
70+
->get(Uid::class);
5871
}
5972

6073
/**
@@ -101,7 +114,7 @@ private function fetch() : array
101114
$linkField = $optionsCollection->getConnection()->getAutoIncrementField($productTable);
102115
$optionsCollection->getSelect()->join(
103116
['cpe' => $productTable],
104-
'cpe.'.$linkField.' = main_table.parent_id',
117+
'cpe.' . $linkField . ' = main_table.parent_id',
105118
[]
106119
)->where(
107120
"cpe.entity_id IN (?)",
@@ -124,6 +137,8 @@ private function fetch() : array
124137
= $option->getTitle() === null ? $option->getDefaultTitle() : $option->getTitle();
125138
$this->optionMap[$option->getParentId()][$option->getId()]['sku']
126139
= $this->skuMap[$option->getParentId()]['sku'];
140+
$this->optionMap[$option->getParentId()][$option->getId()]['uid']
141+
= $this->uidEncoder->encode(self::OPTION_TYPE . '/' . $option->getOptionId());
127142
}
128143

129144
return $this->optionMap;

app/code/Magento/BundleGraphQl/Model/Resolver/Order/Item/BundleOptions.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
1313
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Query\Uid;
1415
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1516
use Magento\Framework\Serialize\Serializer\Json;
1617
use Magento\Sales\Api\Data\InvoiceItemInterface;
@@ -23,6 +24,11 @@
2324
*/
2425
class BundleOptions implements ResolverInterface
2526
{
27+
/**
28+
* Option type name
29+
*/
30+
private const OPTION_TYPE = 'bundle';
31+
2632
/**
2733
* Serializer
2834
*
@@ -35,16 +41,22 @@ class BundleOptions implements ResolverInterface
3541
*/
3642
private $valueFactory;
3743

44+
/** @var Uid */
45+
private $uidEncoder;
46+
3847
/**
3948
* @param ValueFactory $valueFactory
4049
* @param Json $serializer
50+
* @param Uid $uidEncoder
4151
*/
4252
public function __construct(
4353
ValueFactory $valueFactory,
44-
Json $serializer
54+
Json $serializer,
55+
Uid $uidEncoder
4556
) {
4657
$this->valueFactory = $valueFactory;
4758
$this->serializer = $serializer;
59+
$this->uidEncoder = $uidEncoder;
4860
}
4961

5062
/**
@@ -89,7 +101,9 @@ private function getBundleOptions(
89101
foreach ($options['bundle_options'] ?? [] as $bundleOptionId => $bundleOption) {
90102
$bundleOptions[$bundleOptionId]['label'] = $bundleOption['label'] ?? '';
91103
$bundleOptions[$bundleOptionId]['id'] = isset($bundleOption['option_id']) ?
92-
base64_encode($bundleOption['option_id']) : null;
104+
$this->uidEncoder->encode((string) $bundleOption['option_id']) : null;
105+
$bundleOptions[$bundleOptionId]['uid'] = isset($bundleOption['option_id']) ?
106+
$this->uidEncoder->encode(self::OPTION_TYPE . '/' . $bundleOption['option_id']) : null;
93107
if (isset($bundleOption['option_id'])) {
94108
$bundleOptions[$bundleOptionId]['values'] = $this->formatBundleOptionItems(
95109
$item,
@@ -127,8 +141,20 @@ private function formatBundleOptionItems(
127141
// Value Id is missing from parent, so we have to match the child to parent option
128142
if (isset($bundleChildAttributes['option_id'])
129143
&& $bundleChildAttributes['option_id'] == $bundleOptionId) {
144+
145+
$options = $childOrderItemOptions['info_buyRequest']
146+
['bundle_option'][$bundleChildAttributes['option_id']];
147+
148+
$optionDetails = [
149+
self::OPTION_TYPE,
150+
$bundleChildAttributes['option_id'],
151+
implode(',', $options),
152+
(int) $childOrderItemOptions['info_buyRequest']['qty']
153+
];
154+
130155
$optionItems[$childrenOrderItem->getItemId()] = [
131-
'id' => base64_encode($childrenOrderItem->getItemId()),
156+
'id' => $this->uidEncoder->encode((string) $childrenOrderItem->getItemId()),
157+
'uid' => $this->uidEncoder->encode(implode('/', $optionDetails)),
132158
'product_name' => $childrenOrderItem->getName(),
133159
'product_sku' => $childrenOrderItem->getSku(),
134160
'quantity' => $bundleChildAttributes['qty'],

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,24 @@ type BundleCartItem implements CartItemInterface {
3232
}
3333

3434
type SelectedBundleOption {
35-
id: Int!
35+
id: Int! @deprecated(reason: "Use `uid` instead")
36+
uid: ID! @doc(description: "The unique ID for a `SelectedBundleOption` object")
3637
label: String!
3738
type: String!
3839
values: [SelectedBundleOptionValue!]!
3940
}
4041

4142
type SelectedBundleOptionValue {
42-
id: Int!
43+
id: Int! @doc(description: "Use `uid` instead")
44+
uid: ID! @doc(description: "The unique ID for a `SelectedBundleOptionValue` object")
4345
label: String!
4446
quantity: Float!
4547
price: Float!
4648
}
4749

4850
type BundleItem @doc(description: "BundleItem defines an individual item in a bundle product.") {
49-
option_id: Int @doc(description: "An ID assigned to each type of item in a bundle product.")
51+
option_id: Int @deprecated(reason: "Use `uid` instead") @doc(description: "An ID assigned to each type of item in a bundle product.")
52+
uid: ID @doc(description: "The unique ID for a `BundleItem` object.")
5053
title: String @doc(description: "The display name of the item.")
5154
required: Boolean @doc(description: "Indicates whether the item must be included in the bundle.")
5255
type: String @doc(description: "The input type that the customer uses to select the item. Examples include radio button and checkbox.")
@@ -56,7 +59,7 @@ type BundleItem @doc(description: "BundleItem defines an individual item in a bu
5659
}
5760

5861
type BundleItemOption @doc(description: "BundleItemOption defines characteristics and options for a specific bundle item.") {
59-
id: Int @doc(description: "The ID assigned to the bundled item option.")
62+
id: Int @deprecated(reason: "Use `uid` instead") @doc(description: "The ID assigned to the bundled item option.")
6063
label: String @doc(description: "The text that identifies the bundled item option.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\Label")
6164
qty: Float @deprecated(reason: "The `qty` is deprecated. Use `quantity` instead.") @doc(description: "Indicates the quantity of this specific bundle item.")
6265
quantity: Float @doc(description: "Indicates the quantity of this specific bundle item.")
@@ -66,7 +69,7 @@ type BundleItemOption @doc(description: "BundleItemOption defines characteristic
6669
price_type: PriceTypeEnum @doc(description: "One of FIXED, PERCENT, or DYNAMIC.")
6770
can_change_quantity: Boolean @doc(description: "Indicates whether the customer can change the number of items for this option.")
6871
product: ProductInterface @doc(description: "Contains details about this product option.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product")
69-
uid: ID! @doc(description: "A string that encodes option details.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\BundleItemOptionUid") # A Base64 string that encodes option details.
72+
uid: ID! @doc(description: "The unique ID for a `BundleItemOption` object.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\BundleItemOptionUid")
7073
}
7174

7275
type BundleProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "BundleProduct defines basic features of a bundle product and contains multiple BundleItems.") {
@@ -105,13 +108,15 @@ type BundleCreditMemoItem implements CreditMemoItemInterface {
105108
}
106109

107110
type ItemSelectedBundleOption @doc(description: "A list of options of the selected bundle product") {
108-
id: ID! @doc(description: "The unique identifier of the option")
111+
id: ID! @deprecated(reason: "Use `uid` instead") @doc(description: "The unique ID for a `ItemSelectedBundleOption` object")
112+
uid: ID! @doc(description: "The unique ID for a `ItemSelectedBundleOption` object")
109113
label: String! @doc(description: "The label of the option")
110114
values: [ItemSelectedBundleOptionValue] @doc(description: "A list of products that represent the values of the parent option")
111115
}
112116

113117
type ItemSelectedBundleOptionValue @doc(description: "A list of values for the selected bundle product") {
114-
id: ID! @doc(description: "The unique identifier of the value")
118+
id: ID! @deprecated(reason: "Use `uid` instead") @doc(description: "The unique ID for a `ItemSelectedBundleOptionValue` object")
119+
uid: ID! @doc(description: "The unique ID for a `ItemSelectedBundleOptionValue` object")
115120
product_name: String! @doc(description: "The name of the child bundle product")
116121
product_sku: String! @doc(description: "The SKU of the child bundle product")
117122
quantity: Float! @doc(description: "Indicates how many of this bundle product were ordered")

app/code/Magento/Catalog/Controller/Product/Compare/Remove.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Catalog\Controller\Product\Compare;
88

99
use Magento\Catalog\Model\Product\Attribute\Source\Status;
10+
use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection;
1011
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1112
use Magento\Framework\Exception\NoSuchEntityException;
1213

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\Catalog\Model;
10+
11+
use Magento\Framework\Model\AbstractModel;
12+
13+
class CompareList extends AbstractModel
14+
{
15+
/**
16+
* Initialize resource
17+
*
18+
* @return void
19+
*/
20+
protected function _construct()
21+
{
22+
$this->_init(ResourceModel\Product\Compare\CompareList::class);
23+
}
24+
}

0 commit comments

Comments
 (0)