Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

#96 Make category query compatible with staging #99

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getTree(ResolveInfo $resolveInfo, int $rootCategoryId) : array
$collection->addFieldToFilter('level', ['lteq' => $level + $depth - self::DEPTH_OFFSET]);
$collection->setOrder('level');
$collection->getSelect()->orWhere(
$this->metadata->getMetadata(CategoryInterface::class)->getLinkField() . ' = ?',
$this->metadata->getMetadata(CategoryInterface::class)->getIdentifierField() . ' = ?',
$rootCategoryId
);
return $this->processTree($collection->getIterator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\GraphQl\Catalog;

use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
use Magento\Framework\DataObject;
use Magento\TestFramework\TestCase\GraphQlAbstract;
use Magento\Catalog\Api\Data\ProductInterface;
Expand Down Expand Up @@ -286,16 +287,13 @@ public function testCategoryProducts()
*/
public function testAnchorCategory()
{
/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */
$categoryCollection = $this->objectManager->create(
\Magento\Catalog\Model\ResourceModel\Category\Collection::class
);
/** @var CategoryCollection $categoryCollection */
$categoryCollection = $this->objectManager->create(CategoryCollection::class);
$categoryCollection->addFieldToFilter('name', 'Category 1');
/** @var CategoryInterface $category */
$category = $categoryCollection->getFirstItem();
/** @var \Magento\Framework\EntityManager\MetadataPool $entityManagerMetadataPool */
$entityManagerMetadataPool = $this->objectManager->create(\Magento\Framework\EntityManager\MetadataPool::class);
$categoryLinkField = $entityManagerMetadataPool->getMetadata(CategoryInterface::class)->getLinkField();
$categoryId = $category->getData($categoryLinkField);
$categoryId = $category->getId();

$this->assertNotEmpty($categoryId, "Preconditions failed: category is not available.");

$query = <<<QUERY
Expand Down