Skip to content

Commit c1aaae4

Browse files
author
Stanislav Idolov
authored
ENGCOM-2319: #96 Make category query compatible with staging #99
2 parents d4e6297 + e5d7671 commit c1aaae4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/CategoryTree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getTree(ResolveInfo $resolveInfo, int $rootCategoryId) : array
100100
$collection->addFieldToFilter('level', ['lteq' => $level + $depth - self::DEPTH_OFFSET]);
101101
$collection->setOrder('level');
102102
$collection->getSelect()->orWhere(
103-
$this->metadata->getMetadata(CategoryInterface::class)->getLinkField() . ' = ?',
103+
$this->metadata->getMetadata(CategoryInterface::class)->getIdentifierField() . ' = ?',
104104
$rootCategoryId
105105
);
106106
return $this->processTree($collection->getIterator());

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\GraphQl\Catalog;
99

1010
use Magento\Catalog\Api\Data\CategoryInterface;
11+
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
1112
use Magento\Framework\DataObject;
1213
use Magento\TestFramework\TestCase\GraphQlAbstract;
1314
use Magento\Catalog\Api\Data\ProductInterface;
@@ -283,16 +284,13 @@ public function testCategoryProducts()
283284
*/
284285
public function testAnchorCategory()
285286
{
286-
/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */
287-
$categoryCollection = $this->objectManager->create(
288-
\Magento\Catalog\Model\ResourceModel\Category\Collection::class
289-
);
287+
/** @var CategoryCollection $categoryCollection */
288+
$categoryCollection = $this->objectManager->create(CategoryCollection::class);
290289
$categoryCollection->addFieldToFilter('name', 'Category 1');
290+
/** @var CategoryInterface $category */
291291
$category = $categoryCollection->getFirstItem();
292-
/** @var \Magento\Framework\EntityManager\MetadataPool $entityManagerMetadataPool */
293-
$entityManagerMetadataPool = $this->objectManager->create(\Magento\Framework\EntityManager\MetadataPool::class);
294-
$categoryLinkField = $entityManagerMetadataPool->getMetadata(CategoryInterface::class)->getLinkField();
295-
$categoryId = $category->getData($categoryLinkField);
292+
$categoryId = $category->getId();
293+
296294
$this->assertNotEmpty($categoryId, "Preconditions failed: category is not available.");
297295

298296
$query = <<<QUERY

0 commit comments

Comments
 (0)