Magento2 getting single row by field from repository objectFetch Single Record from Custom Module TableMagento2: What's the best way to add custom payment method field?Magento2: Multiple stores (groups) under single websiteSimple Magento2 example of retrieving and displaying a custom table field?Update custom column data in quote table Magento 2Magento:2 How to save unique values for my custom admin moduleGetting product object inside defaultinvoice.php file for getting custom attribute valuesHow to expose a custom field from sales_order table to rest api?Magento 2 Add Record to Custom TableMagento 2 how to Load custom collection data using AjaxGetting a table first row from repository

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Python: next in for loop

In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?

Why are electrically insulating heatsinks so rare? Is it just cost?

What are these boxed doors outside store fronts in New York?

How to format long polynomial?

How old can references or sources in a thesis be?

What does it mean to describe someone as a butt steak?

Prove that NP is closed under karp reduction?

Maximum likelihood parameters deviate from posterior distributions

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

What does "Puller Prush Person" mean?

How can bays and straits be determined in a procedurally generated map?

Fencing style for blades that can attack from a distance

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Why do I get two different answers for this counting problem?

Font hinting is lost in Chrome-like browsers (for some languages )

Do VLANs within a subnet need to have their own subnet for router on a stick?

What's the output of a record cartridge playing an out-of-speed record

Why doesn't H₄O²⁺ exist?

Problem of parity - Can we draw a closed path made up of 20 line segments...

What is the word for reserving something for yourself before others do?



Magento2 getting single row by field from repository object


Fetch Single Record from Custom Module TableMagento2: What's the best way to add custom payment method field?Magento2: Multiple stores (groups) under single websiteSimple Magento2 example of retrieving and displaying a custom table field?Update custom column data in quote table Magento 2Magento:2 How to save unique values for my custom admin moduleGetting product object inside defaultinvoice.php file for getting custom attribute valuesHow to expose a custom field from sales_order table to rest api?Magento 2 Add Record to Custom TableMagento 2 how to Load custom collection data using AjaxGetting a table first row from repository






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








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.










share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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
    May 28 '17 at 12:47

















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.










share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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
    May 28 '17 at 12:47













0












0








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.










share|improve this question














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.







magento2 magento-2.1






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 28 '17 at 7:48









dondon

362




362





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • 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
    May 28 '17 at 12:47

















  • 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
    May 28 '17 at 12:47
















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
May 28 '17 at 12:47





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
May 28 '17 at 12:47










1 Answer
1






active

oldest

votes


















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();





share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f176360%2fmagento2-getting-single-row-by-field-from-repository-object%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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();





    share|improve this answer



























      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();





      share|improve this answer

























        0












        0








        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();





        share|improve this answer













        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();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 28 '17 at 12:49









        Kishan PatadiaKishan Patadia

        3,8451925




        3,8451925



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f176360%2fmagento2-getting-single-row-by-field-from-repository-object%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form