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

  • You have to just remove @api and param integer $id lline from comment and check. – Rakesh Jesadiya Jun 8 '17 at 8:45
  • Not sure why I should do that. The problem is with @return declaration. – Pete Jaworski Jun 8 '17 at 9:12
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, privacy policy and cookie policy

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