Skip to content

Commit

Permalink
MAGETWO-59727: [Backport] - [Github] REST API with searchCriteria doe…
Browse files Browse the repository at this point in the history
…s not return category_ids #6127 - for 2.0
  • Loading branch information
RomaKis committed Nov 18, 2016
1 parent ca68e6e commit bb8e1f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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 @@ -679,6 +679,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
$collection->setCurPage($searchCriteria->getCurrentPage());
$collection->setPageSize($searchCriteria->getPageSize());
$collection->load();
$collection->addCategoryIds();

$searchResult = $this->searchResultsFactory->create();
$searchResult->setSearchCriteria($searchCriteria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ public function testGetList($fieldName)
$searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(42);
$collectionMock->expects($this->once())->method('setPageSize')->with(42);
$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 @@ -574,7 +574,19 @@ public function testGetList()

$this->assertNotNull($response['items'][0]['sku']);
$this->assertEquals('simple', $response['items'][0]['sku']);
}


$index = null;
foreach ($response['items'][0]['custom_attributes'] as $key => $customAttribute) {
if ($customAttribute['attribute_code'] == 'category_ids') {
$index = $key;
break;
}
}
$this->assertNotNull($index, 'Category information wasn\'t set');

$expectedResult = (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) ? ['string' => '2'] : ['2'];
$this->assertEquals($expectedResult, $response['items'][0]['custom_attributes'][$index]['value']); }

/**
* @param $customAttributes
Expand Down

0 comments on commit bb8e1f8

Please sign in to comment.