Skip to content

Commit fa0cb04

Browse files
Merge pull request #110 from andimov/ACPT-1876
ACPT-1876: Cloud quality patch for Application Server
2 parents f342890 + 5e7f1bd commit fa0cb04

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

patches.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,5 +410,10 @@
410410
"Fix regexp cache tag validation": {
411411
">=103.0.6 <103.0.7": "MCLOUD-10226__fix_regexp_cache_tag_validation__2.4.6.patch"
412412
}
413+
},
414+
"magento/module-catalog-graph-ql": {
415+
"AttributeReader should use Factory for Collection": {
416+
">=100.4.7 <100.4.8": "ACPT-1876__attribute_reader_should_use_factory_for_collection__2.4.7.patch"
417+
}
413418
}
414419
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
From c964bc3248811dc63df6205a1246d383ad4c6e4a Mon Sep 17 00:00:00 2001
2+
From: Jacob Brown <[email protected]>
3+
Date: Wed, 3 Apr 2024 14:07:21 -0500
4+
Subject: [PATCH] ACPT-1854: AttributeReader should use Factory for Collection
5+
6+
---
7+
.../Model/Config/AttributeReader.php | 18 +++++++++++-------
8+
1 file changed, 11 insertions(+), 7 deletions(-)
9+
10+
diff --git a/vendor/magento/module-catalog-graph-ql/Model/Config/AttributeReader.php b/vendor/magento/module-catalog-graph-ql/Model/Config/AttributeReader.php
11+
index ecd83bf61ef0..05acb97e4bd7 100644
12+
--- a/vendor/magento/module-catalog-graph-ql/Model/Config/AttributeReader.php
13+
+++ b/vendor/magento/module-catalog-graph-ql/Model/Config/AttributeReader.php
14+
@@ -9,8 +9,10 @@
15+
use Magento\Catalog\Model\Product;
16+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
17+
use Magento\CatalogGraphQl\Model\Resolver\Products\Attributes\Collection;
18+
+use Magento\CatalogGraphQl\Model\Resolver\Products\Attributes\CollectionFactory;
19+
use Magento\EavGraphQl\Model\Resolver\Query\Type;
20+
use Magento\Framework\App\Config\ScopeConfigInterface;
21+
+use Magento\Framework\App\ObjectManager;
22+
use Magento\Framework\Config\ReaderInterface;
23+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
24+
use Magento\Framework\GraphQl\Schema\Type\Entity\MapperInterface;
25+
@@ -36,9 +38,9 @@ class AttributeReader implements ReaderInterface
26+
private Type $typeLocator;
27+
28+
/**
29+
- * @var Collection
30+
+ * @var CollectionFactory
31+
*/
32+
- private Collection $collection;
33+
+ private CollectionFactory $collectionFactory;
34+
35+
/**
36+
* @var ScopeConfigInterface
37+
@@ -48,18 +50,21 @@ class AttributeReader implements ReaderInterface
38+
/**
39+
* @param MapperInterface $mapper
40+
* @param Type $typeLocator
41+
- * @param Collection $collection
42+
+ * @param Collection $collection @deprecated @see $collectionFactory
43+
* @param ScopeConfigInterface $config
44+
+ * @param CollectionFactory|null $collectionFactory
45+
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
46+
*/
47+
public function __construct(
48+
MapperInterface $mapper,
49+
Type $typeLocator,
50+
Collection $collection,
51+
- ScopeConfigInterface $config
52+
+ ScopeConfigInterface $config,
53+
+ CollectionFactory $collectionFactory = null,
54+
) {
55+
$this->mapper = $mapper;
56+
$this->typeLocator = $typeLocator;
57+
- $this->collection = $collection;
58+
+ $this->collectionFactory = $collectionFactory ?? ObjectManager::getInstance()->get(CollectionFactory::class);
59+
$this->config = $config;
60+
}
61+
62+
@@ -74,12 +79,11 @@ public function __construct(
63+
public function read($scope = null) : array
64+
{
65+
$config = [];
66+
-
67+
if ($this->config->isSetFlag(self::XML_PATH_INCLUDE_DYNAMIC_ATTRIBUTES, ScopeInterface::SCOPE_STORE)) {
68+
$typeNames = $this->mapper->getMappedTypes(Product::ENTITY);
69+
70+
/** @var Attribute $attribute */
71+
- foreach ($this->collection->getAttributes() as $attribute) {
72+
+ foreach ($this->collectionFactory->create()->getAttributes() as $attribute) {
73+
$attributeCode = $attribute->getAttributeCode();
74+
$locatedType = $this->typeLocator->getType($attributeCode, Product::ENTITY) ?: 'String';
75+
$locatedType = TypeProcessor::NORMALIZED_ANY_TYPE === $locatedType ? 'String' : ucfirst($locatedType);

0 commit comments

Comments
 (0)