0

I am building an ajax using webapi. and it instantiates a repository model. How do I load a single row by a field? I need to check if an email already exist in the table.

1
  • Loading an object from model or can say getting one row from table is same as it's in magento1 see this link magento.stackexchange.com/questions/33019/… , the only difference is to load or initiate a model or collection.
    – Kumar M
    Commented May 28, 2017 at 12:47

1 Answer 1

0

I think you can load first item as follows from model.

$firstItem = $repositoryObject->create()->getCollection()->getFirstItem();

And if you want field name then as follows.

$firstItemField = $repositoryObject->create()->getCollection()->getFirstItem()->getXxx();

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.