Skip to content

Commit 3ce8aa6

Browse files
authored
ENGCOM-4137: Fixed issue #334 Changed hard coded values according to TYPE_CODE #340
2 parents cea36f0 + c0543b1 commit 3ce8aa6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app/code/Magento/BundleGraphQl/Model/BundleProductTypeResolver.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
namespace Magento\BundleGraphQl\Model;
99

1010
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11+
use Magento\Bundle\Model\Product\Type as Type;
1112

1213
/**
1314
* {@inheritdoc}
1415
*/
1516
class BundleProductTypeResolver implements TypeResolverInterface
1617
{
18+
const BUNDLE_PRODUCT = 'BundleProduct';
19+
1720
/**
1821
* {@inheritdoc}
1922
*/
2023
public function resolveType(array $data) : string
2124
{
22-
if (isset($data['type_id']) && $data['type_id'] == 'bundle') {
23-
return 'BundleProduct';
25+
if (isset($data['type_id']) && $data['type_id'] == Type::TYPE_CODE) {
26+
return self::BUNDLE_PRODUCT;
2427
}
2528
return '';
2629
}

app/code/Magento/DownloadableGraphQl/Model/DownloadableProductTypeResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@
88
namespace Magento\DownloadableGraphQl\Model;
99

1010
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11+
use Magento\Downloadable\Model\Product\Type as Type;
1112

1213
/**
1314
* {@inheritdoc}
1415
*/
1516
class DownloadableProductTypeResolver implements TypeResolverInterface
1617
{
18+
const DOWNLOADABLE_PRODUCT = 'DownloadableProduct';
1719
/**
1820
* {@inheritdoc}
1921
*/
2022
public function resolveType(array $data) : string
2123
{
22-
if (isset($data['type_id']) && $data['type_id'] == 'downloadable') {
23-
return 'DownloadableProduct';
24+
if (isset($data['type_id']) && $data['type_id'] == Type::TYPE_DOWNLOADABLE) {
25+
return self::DOWNLOADABLE_PRODUCT;
2426
}
2527
return '';
2628
}

app/code/Magento/GroupedProductGraphQl/Model/GroupedProductTypeResolver.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88
namespace Magento\GroupedProductGraphQl\Model;
99

1010
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11-
11+
use Magento\GroupedProduct\Model\Product\Type\Grouped as Type;
1212
/**
1313
* {@inheritdoc}
1414
*/
1515
class GroupedProductTypeResolver implements TypeResolverInterface
1616
{
17+
const GROUPED_PRODUCT = 'GroupedProduct';
1718
/**
1819
* {@inheritdoc}
1920
*/
2021
public function resolveType(array $data) : string
2122
{
22-
if (isset($data['type_id']) && $data['type_id'] == 'grouped') {
23-
return 'GroupedProduct';
23+
if (isset($data['type_id']) && $data['type_id'] == Type::TYPE_CODE) {
24+
return self::GROUPED_PRODUCT;
2425
}
2526
return '';
2627
}

0 commit comments

Comments
 (0)