-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/2.3-develop' into libs-upgrade
# Conflicts: # app/code/Magento/EavGraphQl/composer.json # app/code/Magento/GroupedProductGraphQl/composer.json # app/code/Magento/SwatchesGraphQl/composer.json
- Loading branch information
Showing
398 changed files
with
23,686 additions
and
7,279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
...Magento/BundleGraphQl/Model/Plugin/Model/Resolver/Products/DataProvider/ProductPlugin.php
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
app/code/Magento/BundleGraphQl/Model/Resolver/BundleItemLinks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\BundleGraphQl\Model\Resolver; | ||
|
||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\BundleGraphQl\Model\Resolver\Links\Collection; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\Resolver\Value; | ||
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
class BundleItemLinks implements ResolverInterface | ||
{ | ||
/** | ||
* @var Collection | ||
*/ | ||
private $linkCollection; | ||
|
||
/** | ||
* @var ValueFactory | ||
*/ | ||
private $valueFactory; | ||
|
||
/** | ||
* @param Collection $linkCollection | ||
* @param ValueFactory $valueFactory | ||
*/ | ||
public function __construct( | ||
Collection $linkCollection, | ||
ValueFactory $valueFactory | ||
) { | ||
$this->linkCollection = $linkCollection; | ||
$this->valueFactory = $valueFactory; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value | ||
{ | ||
if (!isset($value['option_id']) || !isset($value['parent_id'])) { | ||
$result = function () { | ||
return null; | ||
}; | ||
return $this->valueFactory->create($result); | ||
} | ||
$this->linkCollection->addIdFilters((int)$value['option_id'], (int)$value['parent_id']); | ||
$result = function () use ($value) { | ||
return $this->linkCollection->getLinksForOptionId((int)$value['option_id']); | ||
}; | ||
|
||
return $this->valueFactory->create($result); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
app/code/Magento/BundleGraphQl/Model/Resolver/BundleItems.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\BundleGraphQl\Model\Resolver; | ||
|
||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Bundle\Model\Product\Type; | ||
use Magento\BundleGraphQl\Model\Resolver\Options\Collection; | ||
use Magento\Catalog\Api\Data\ProductInterface; | ||
use Magento\Framework\EntityManager\MetadataPool; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\Resolver\Value; | ||
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
class BundleItems implements ResolverInterface | ||
{ | ||
/** | ||
* @var Collection | ||
*/ | ||
private $bundleOptionCollection; | ||
|
||
/** | ||
* @var ValueFactory | ||
*/ | ||
private $valueFactory; | ||
|
||
/** | ||
* @var MetadataPool | ||
*/ | ||
private $metdataPool; | ||
|
||
/** | ||
* @param Collection $bundleOptionCollection | ||
* @param ValueFactory $valueFactory | ||
* @param MetadataPool $metdataPool | ||
*/ | ||
public function __construct( | ||
Collection $bundleOptionCollection, | ||
ValueFactory $valueFactory, | ||
MetadataPool $metdataPool | ||
) { | ||
$this->bundleOptionCollection = $bundleOptionCollection; | ||
$this->valueFactory = $valueFactory; | ||
$this->metdataPool = $metdataPool; | ||
} | ||
|
||
/** | ||
* Fetch and format bundle option items. | ||
* | ||
* {@inheritDoc} | ||
*/ | ||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value | ||
{ | ||
$linkField = $this->metdataPool->getMetadata(ProductInterface::class)->getLinkField(); | ||
if ($value['type_id'] !== Type::TYPE_CODE | ||
|| !isset($value[$linkField]) | ||
|| !isset($value[ProductInterface::SKU]) | ||
) { | ||
$result = function () { | ||
return null; | ||
}; | ||
return $this->valueFactory->create($result); | ||
} | ||
|
||
$this->bundleOptionCollection->addParentFilterData( | ||
(int)$value[$linkField], | ||
(int)$value['entity_id'], | ||
$value[ProductInterface::SKU] | ||
); | ||
|
||
$result = function () use ($value, $linkField) { | ||
return $this->bundleOptionCollection->getOptionsByParentId((int)$value[$linkField]); | ||
}; | ||
|
||
return $this->valueFactory->create($result); | ||
} | ||
} |
Oops, something went wrong.