Skip to content

Commit

Permalink
MAGETWO-59130: [Github] REST API with searchCriteria does not return …
Browse files Browse the repository at this point in the history
…category_ids #6127
  • Loading branch information
irenelagno committed Oct 13, 2016
1 parent f491ac8 commit 2760b1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr

$collection->load();

$collection->addCategoryIds();
$searchResult = $this->searchResultsFactory->create();
$searchResult->setSearchCriteria($searchCriteria);
$searchResult->setItems($collection->getItems());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ public function testGetList()
->method('process')
->with($searchCriteriaMock, $collectionMock);
$collectionMock->expects($this->once())->method('load');
$collectionMock->expects($this->once())->method('addCategoryIds');
$collectionMock->expects($this->once())->method('getItems')->willReturn([$itemsMock]);
$collectionMock->expects($this->once())->method('getSize')->willReturn(128);
$searchResultsMock = $this->getMock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,16 @@ public function testGetList()

$this->assertNotNull($response['items'][0]['sku']);
$this->assertEquals('simple', $response['items'][0]['sku']);
$isCategoryInformationExist = false;
$index = null;
foreach($response['items'][0]['custom_attributes'] as $key => $customAttribute) {
if ($customAttribute['attribute_code'] == 'category_ids') {
$isCategoryInformationExist = true;
$index = $key;
}
}
$this->assertTrue($isCategoryInformationExist, 'Category information wasn\'t set');
$this->assertEquals([2], $response['items'][0]['custom_attributes'][$index]['value']);
}

/**
Expand Down

3 comments on commit 2760b1c

@Ctucker9233
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irenelagno Will MAGETWO-59130 be included in 2.1.3?

@gehirnstuerm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not included in 2.1.6?

@ishakhsuvarov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gehirnstuerm Looks like it's not in 2.1.6. We are now accepting Pull Requests to the 2.1-develop branch. You may submit one if you wish, that will speed up adding the fix to the future patch release.
Thanks

Please sign in to comment.