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

Commit

Permalink
#96 Made category api compatible with Content Staging Commerce feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Glushko committed Jun 30, 2018
1 parent f947cad commit e79f381
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 e79f381

Please sign in to comment.