1

Sometimes, i used function getData() and get a different result with getItems(). what is different of them?

1
  • Thanks mate. +1 for answer acceptance :) Nov 28, 2019 at 6:26

2 Answers 2

5
getItems()

will return collection in ORM (Object)

where as

getData() 

will return data in array form.

You cannot use any further functions on getData() but in getItems() you can use further functions.

Like: if you are using cart object, and you use getItems() then in foreach loop you can use function $item->getProduct(); but you cannot do this in getData

1
3
getData()

its return the data in an array based on the filter used on collection.

getItems() it returns object list.

getData() returns data as an array while getItems() returns objectlist.

2

Your Answer

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

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