Skip to content

Commit

Permalink
ENGCOM-2319: #96 Make category query compatible with staging #99
Browse files Browse the repository at this point in the history
 - Merge Pull Request magento/graphql-ce#99 from magento/graphql-ce:96-compatibility-with-content-staging
 - Merged commits:
   1. e79f381
  • Loading branch information
magento-engcom-team committed Jul 13, 2018
2 parents ce5eacd + e79f381 commit e5d7671
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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

0 comments on commit e5d7671

Please sign in to comment.