Skip to content

Commit e5d7671

Browse files
ENGCOM-2319: #96 Make category query compatible with staging #99
- Merge Pull Request magento/graphql-ce#99 from magento/graphql-ce:96-compatibility-with-content-staging - Merged commits: 1. e79f381
2 parents ce5eacd + e79f381 commit e5d7671

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;
@@ -286,16 +287,13 @@ public function testCategoryProducts()
286287
*/
287288
public function testAnchorCategory()
288289
{
289-
/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */
290-
$categoryCollection = $this->objectManager->create(
291-
\Magento\Catalog\Model\ResourceModel\Category\Collection::class
292-
);
290+
/** @var CategoryCollection $categoryCollection */
291+
$categoryCollection = $this->objectManager->create(CategoryCollection::class);
293292
$categoryCollection->addFieldToFilter('name', 'Category 1');
293+
/** @var CategoryInterface $category */
294294
$category = $categoryCollection->getFirstItem();
295-
/** @var \Magento\Framework\EntityManager\MetadataPool $entityManagerMetadataPool */
296-
$entityManagerMetadataPool = $this->objectManager->create(\Magento\Framework\EntityManager\MetadataPool::class);
297-
$categoryLinkField = $entityManagerMetadataPool->getMetadata(CategoryInterface::class)->getLinkField();
298-
$categoryId = $category->getData($categoryLinkField);
295+
$categoryId = $category->getId();
296+
299297
$this->assertNotEmpty($categoryId, "Preconditions failed: category is not available.");
300298

301299
$query = <<<QUERY

0 commit comments

Comments
 (0)