Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-catalog-graph-ql
Model
Config
AttributeReader.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\CatalogGraphQl\Model\Config
;
8
9
use
Magento\Framework\Config\ReaderInterface
;
10
use
Magento\Framework\GraphQl\Exception\GraphQlInputException
;
11
use
Magento\Framework\GraphQl\Schema\Type\Entity\MapperInterface
;
12
use
Magento\Framework\Reflection\TypeProcessor
;
13
use
Magento\EavGraphQl\Model\Resolver\Query\Type
;
14
use
Magento\CatalogGraphQl\Model\Resolver\Products\Attributes\Collection
;
15
19
class
AttributeReader
implements
ReaderInterface
20
{
24
private
$mapper;
25
29
private
$typeLocator;
30
34
private
$collection;
35
41
public
function
__construct
(
42
MapperInterface
$mapper,
43
Type
$typeLocator,
44
Collection
$collection
45
) {
46
$this->mapper = $mapper;
47
$this->typeLocator = $typeLocator;
48
$this->collection =
$collection
;
49
}
50
59
public
function
read
($scope =
null
) : array
60
{
61
$typeNames = $this->mapper->getMappedTypes(\
Magento
\Catalog\Model\Product::ENTITY);
62
$config
=[];
64
foreach
($this->collection->getAttributes() as
$attribute
) {
65
$attributeCode
=
$attribute
->getAttributeCode();
66
$locatedType = $this->typeLocator->getType(
67
$attributeCode
,
68
\
Magento
\Catalog\Model\Product::ENTITY
69
) ?:
'String'
;
70
$locatedType = $locatedType ===
TypeProcessor::NORMALIZED_ANY_TYPE
?
'String'
: ucfirst($locatedType);
71
foreach
($typeNames as $typeName) {
72
$config
[$typeName][
'fields'
][
$attributeCode
] = [
73
'name'
=>
$attributeCode
,
74
'type'
=> $locatedType,
75
'arguments'
=> []
76
];
77
}
78
}
79
80
return
$config
;
81
}
82
}
Magento\Framework\GraphQl\Schema\Type\Entity\MapperInterface
Definition:
MapperInterface.php:13
Magento\CatalogGraphQl\Model\Config
Definition:
AttributeReader.php:7
Magento\EavGraphQl\Model\Resolver\Query\Type
Definition:
Type.php:20
$config
$config
Definition:
fraud_order.php:17
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
Magento\Framework\Reflection\TypeProcessor
Definition:
TypeProcessor.php:24
Magento\Framework\Reflection\TypeProcessor\NORMALIZED_ANY_TYPE
const NORMALIZED_ANY_TYPE
Definition:
TypeProcessor.php:43
Magento\CatalogGraphQl\Model\Config\AttributeReader\__construct
__construct(MapperInterface $mapper, Type $typeLocator, Collection $collection)
Definition:
AttributeReader.php:41
Magento\Framework\Config\ReaderInterface
Definition:
ReaderInterface.php:16
$attributeCode
$attributeCode
Definition:
extend.phtml:12
Magento
Magento\CatalogGraphQl\Model\Resolver\Products\Attributes\Collection
Definition:
Collection.php:18
Magento\Framework\Config\ReaderInterface\read
read($scope=null)
Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection
Definition:
Collection.php:13
$collection
$collection
Definition:
catalog_category_with_apostrophe_rollback.php:17
Magento\CatalogGraphQl\Model\Config\AttributeReader
Definition:
AttributeReader.php:19
Magento\Framework\GraphQl\Exception\GraphQlInputException
Definition:
GraphQlInputException.php:16