1

I'm playing with M2 API. I built a test module that returns specific Order items in JSON format. I set @return as 'string' (see screenshot below).

Problem: I'm getting error: Class string does not exist.

Question: how should I set @return in phpbloc to get it work properly?

enter image description here

2
  • You have to just remove @api and param integer $id lline from comment and check. Jun 8, 2017 at 8:45
  • Not sure why I should do that. The problem is with @return declaration. Jun 8, 2017 at 9:12

1 Answer 1

0

Solution: function returns bunch of Order items so this is how @return should look like:

/**
 * Returns order details 
 *
 * @api
 * @param integer $id Order id.
 * @return \Magento\Sales\Api\Data\OrderItemInterface[]
 */

It will automatically returns then in JSON format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.