Skip to content

Commit 44aa193

Browse files
committed
Merge branch '2.4-develop' into ACP2E-1245
2 parents 2fdfdc9 + 5a022f6 commit 44aa193

File tree

42 files changed

+3955
-8439
lines changed

Some content is hidden

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

42 files changed

+3955
-8439
lines changed

app/code/Magento/Backend/view/adminhtml/web/js/dashboard/chart.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ define([
99
'chartJs',
1010
'jquery-ui-modules/widget',
1111
'chartjs/chartjs-adapter-moment',
12+
'chartjs/es6-shim.min',
1213
'moment'
1314
], function ($, Chart) {
1415
'use strict';

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
3131
/**
3232
* Product type
3333
*/
34-
const TYPE_CODE = 'bundle';
34+
public const TYPE_CODE = 'bundle';
3535

3636
/**
3737
* Product is composite
@@ -52,6 +52,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
5252
*
5353
* @var string
5454
* @deprecated 100.2.0
55+
* @see MAGETWO-71174
5556
*/
5657
protected $_keySelectionsCollection = '_cache_instance_selections_collection';
5758

@@ -91,14 +92,14 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
9192
protected $_canConfigure = true;
9293

9394
/**
94-
* Catalog data
95+
* Catalog data helper
9596
*
9697
* @var \Magento\Catalog\Helper\Data
9798
*/
9899
protected $_catalogData = null;
99100

100101
/**
101-
* Catalog product
102+
* Catalog product helper
102103
*
103104
* @var \Magento\Catalog\Helper\Product
104105
*/
@@ -1286,7 +1287,7 @@ protected function checkIsAllRequiredOptions($product, $isStrictProcessMode, $op
12861287
{
12871288
if (!$product->getSkipCheckRequiredOption() && $isStrictProcessMode) {
12881289
foreach ($optionsCollection->getItems() as $option) {
1289-
if ($option->getRequired() && !isset($options[$option->getId()])) {
1290+
if ($option->getRequired() && empty($options[$option->getId()])) {
12901291
throw new \Magento\Framework\Exception\LocalizedException(
12911292
__('Please select all required options.')
12921293
);
@@ -1421,6 +1422,7 @@ protected function mergeSelectionsWithOptions($options, $selections)
14211422
/**
14221423
* Get prepared options with selection ids
14231424
*
1425+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
14241426
* @param array $options
14251427
* @return array
14261428
*/

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ private function fetch() : array
112112

113113
$productTable = $optionsCollection->getTable('catalog_product_entity');
114114
$linkField = $optionsCollection->getConnection()->getAutoIncrementField($productTable);
115+
$entityIds = array_column($this->skuMap, 'entity_id');
116+
115117
$optionsCollection->getSelect()->join(
116118
['cpe' => $productTable],
117119
'cpe.' . $linkField . ' = main_table.parent_id',
118120
[]
119121
)->where(
120122
"cpe.entity_id IN (?)",
121-
$this->skuMap
123+
$entityIds
122124
);
123125
$optionsCollection->setPositionOrder();
124126

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Framework\GraphQl\Query\ResolverInterface;
1616

1717
/**
18-
* Class Label
18+
* Bundle product option label resolver
1919
*/
2020
class Label implements ResolverInterface
2121
{
@@ -56,8 +56,8 @@ public function resolve(
5656
$this->product->addProductSku($value['sku']);
5757
$this->product->addEavAttributes(['name']);
5858

59-
$result = function () use ($value) {
60-
$productData = $this->product->getProductBySku($value['sku']);
59+
$result = function () use ($value, $context) {
60+
$productData = $this->product->getProductBySku($value['sku'], $context);
6161
/** @var \Magento\Catalog\Model\Product $productModel */
6262
$productModel = isset($productData['model']) ? $productData['model'] : null;
6363
return $productModel ? $productModel->getName() : null;

app/code/Magento/BundleGraphQl/Model/Resolver/PriceRange.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function resolve(
7373
array $args = null
7474
) {
7575
$this->productDataProvider->addProductSku($value['sku']);
76-
$productData = $this->productDataProvider->getProductBySku($value['sku']);
76+
$productData = $this->productDataProvider->getProductBySku($value['sku'], $context);
7777
$value['model'] = $productData['model'];
7878

7979
return $this->priceRangeDataProvider->prepare($context, $info, $value);

app/code/Magento/BundleGraphQl/etc/graphql/di.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,22 @@
114114
</argument>
115115
</arguments>
116116
</type>
117+
<type name="Magento\BundleGraphQl\Model\Resolver\Options\Label">
118+
<arguments>
119+
<argument name="product" xsi:type="object">Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Deferred\ChildProduct</argument>
120+
</arguments>
121+
</type>
122+
<type name="Magento\BundleGraphQl\Model\Resolver\PriceRange">
123+
<arguments>
124+
<argument name="productDataProvider" xsi:type="object">Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Deferred\ChildProduct</argument>
125+
</arguments>
126+
</type>
127+
<virtualType name="Magento\BundleGraphQl\Model\Resolver\Options\Product"
128+
type="Magento\CatalogGraphQl\Model\Resolver\Product">
129+
<arguments>
130+
<argument name="productDataProvider" xsi:type="object">
131+
Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Deferred\ChildProduct
132+
</argument>
133+
</arguments>
134+
</virtualType>
117135
</config>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type BundleItemOption @doc(description: "Defines the characteristics that compri
6969
price: Float @doc(description: "The price of the selected option.")
7070
price_type: PriceTypeEnum @doc(description: "One of FIXED, PERCENT, or DYNAMIC.")
7171
can_change_quantity: Boolean @doc(description: "Indicates whether the customer can change the number of items for this option.")
72-
product: ProductInterface @doc(description: "Contains details about this product option.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product")
72+
product: ProductInterface @doc(description: "Contains details about this product option.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\Product")
7373
uid: ID! @doc(description: "The unique ID for a `BundleItemOption` object.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\BundleItemOptionUid")
7474
}
7575

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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\Catalog\Model\ResourceModel\Product;
9+
10+
/**
11+
* Factory class for child product collection
12+
*/
13+
class ChildCollectionFactory extends CollectionFactory
14+
{
15+
/**
16+
* Create class instance with specified parameters
17+
*
18+
* @param array $data
19+
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
20+
*/
21+
public function create(array $data = [])
22+
{
23+
$collection = parent::create($data);
24+
$collection->setFlag('product_children', true);
25+
return $collection;
26+
}
27+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\Catalog\Model\ResourceModel\Product;
9+
10+
/**
11+
* Factory class for @see \Magento\Catalog\Model\ResourceModel\Product\Collection
12+
*/
13+
class CollectionFactory
14+
{
15+
/**
16+
* Object Manager instance
17+
*
18+
* @var \Magento\Framework\ObjectManagerInterface
19+
*/
20+
private $objectManager = null;
21+
22+
/**
23+
* Instance name to create
24+
*
25+
* @var string
26+
*/
27+
private $instanceName = null;
28+
29+
/**
30+
* Factory constructor
31+
*
32+
* @param \Magento\Framework\ObjectManagerInterface $objectManager
33+
* @param string $instanceName
34+
*/
35+
public function __construct(
36+
\Magento\Framework\ObjectManagerInterface $objectManager,
37+
$instanceName = Collection::class
38+
) {
39+
$this->objectManager = $objectManager;
40+
$this->instanceName = $instanceName;
41+
}
42+
43+
/**
44+
* Create class instance with specified parameters
45+
*
46+
* @param array $data
47+
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
48+
*/
49+
public function create(array $data = [])
50+
{
51+
return $this->objectManager->create($this->instanceName, $data);
52+
}
53+
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
6363
$fields = $this->productFieldsSelector->getProductFieldsFromInfo($info);
6464
$this->productDataProvider->addEavAttributes($fields);
6565

66-
$result = function () use ($value) {
67-
$data = $value['product'] ?? $this->productDataProvider->getProductBySku($value['sku']);
66+
$result = function () use ($value, $context) {
67+
$data = $value['product'] ?? $this->productDataProvider->getProductBySku($value['sku'], $context);
6868
if (empty($data)) {
6969
return null;
7070
}

0 commit comments

Comments
 (0)