Guest User

Untitled

a guest
Jan 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. foreach ($item->getCustomAttributes() as $attribute)
  2.  
  3. /**
  4. * @param SearchResultInterface $searchResult
  5. * @return array
  6. */
  7. protected function searchResultToOutput(SearchResultInterface $searchResult)
  8. {
  9. $arrItems = [];
  10.  
  11. $arrItems['items'] = [];
  12. foreach ($searchResult->getItems() as $item) {
  13. $itemData = [];
  14. /* THROWS ERROR foreach ($item->getCustomAttributes() as $attribute) {
  15. $itemData[$attribute->getAttributeCode()] = $attribute->getValue();
  16. } */
  17. $arrItems['items'][] = $itemData;
  18. }
  19.  
  20. $arrItems['totalRecords'] = $searchResult->getTotalCount();
  21. return $arrItems;
  22.  
  23. }
Add Comment
Please, Sign In to add comment