Skip to content

Commit 73415a6

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-commerce/magento2ce into ACP2E-1117
2 parents 205b2de + 5a022f6 commit 73415a6

File tree

36 files changed

+3668
-8433
lines changed

36 files changed

+3668
-8433
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/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
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Deferred/Product.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ public function addEavAttributes(array $attributeCodes) : void
103103
* Get product from result set.
104104
*
105105
* @param string $sku
106+
* @param null|ContextInterface $context
106107
* @return array
107108
*/
108-
public function getProductBySku(string $sku) : array
109+
public function getProductBySku(string $sku, ContextInterface $context = null) : array
109110
{
110-
$products = $this->fetch();
111+
$products = $this->fetch($context);
111112

112113
if (!isset($products[$sku])) {
113114
return [];
@@ -119,9 +120,10 @@ public function getProductBySku(string $sku) : array
119120
/**
120121
* Fetch product data and return in array format. Keys for products will be their skus.
121122
*
123+
* @param null|ContextInterface $context
122124
* @return array
123125
*/
124-
private function fetch() : array
126+
private function fetch(ContextInterface $context = null) : array
125127
{
126128
if (empty($this->productSkus) || !empty($this->productList)) {
127129
return $this->productList;
@@ -132,7 +134,8 @@ private function fetch() : array
132134
$this->searchCriteriaBuilder->create(),
133135
$this->attributeCodes,
134136
false,
135-
false
137+
true,
138+
$context
136139
);
137140

138141
/** @var \Magento\Catalog\Model\Product $product */

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/VisibilityStatusProcessor.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public function process(
3737
): Collection {
3838
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
3939
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
40+
if ($context) {
41+
$store = $context->getExtensionAttributes()->getStore();
42+
if ($store) {
43+
$websiteId = $store->getWebsiteId();
44+
$collection->addWebsiteFilter([$websiteId]);
45+
}
46+
}
4047

4148
return $collection;
4249
}

0 commit comments

Comments
 (0)