addFieldToFilter in magento2 returning same data everytime Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento 2 CMS Page getList() repository methods does not return expected objectaddFieldToFilter() And Condition in magento2Error Add Result page breadcrumbMagento 2.2 error: Unable to unserialize valueMagento 2.2 - Cannot update attribute valuesCannot save customer programaticallyfilter data using addFieldToFilter() Condition in block file magento2Magento2 UI Component admin Grid / Listing stuck loadingConvert(re-write) array_filter code into foreach loopsearchCriteria returning every result

Is multiple magic items in one inherently imbalanced?

Semigroups with no morphisms between them

What does 丫 mean? 丫是什么意思?

Do wooden building fires get hotter than 600°C?

How does Belgium enforce obligatory attendance in elections?

How could we fake a moon landing now?

Did any compiler fully use 80-bit floating point?

Why are my pictures showing a dark band on one edge?

The test team as an enemy of development? And how can this be avoided?

Draw 4 of the same figure in the same tikzpicture

Crossing US/Canada Border for less than 24 hours

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

What order were files/directories output in dir?

A term for a woman complaining about things/begging in a cute/childish way

Tannaka duality for semisimple groups

Putting class ranking in CV, but against dept guidelines

What is the meaning of 'breadth' in breadth first search?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

preposition before coffee

What initially awakened the Balrog?

What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?

Dyck paths with extra diagonals from valleys (Laser construction)

How to identify unknown coordinate type and convert to lat/lon?

macOS: Name for app shortcut screen found by pinching with thumb and three fingers



addFieldToFilter in magento2 returning same data everytime



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2 CMS Page getList() repository methods does not return expected objectaddFieldToFilter() And Condition in magento2Error Add Result page breadcrumbMagento 2.2 error: Unable to unserialize valueMagento 2.2 - Cannot update attribute valuesCannot save customer programaticallyfilter data using addFieldToFilter() Condition in block file magento2Magento2 UI Component admin Grid / Listing stuck loadingConvert(re-write) array_filter code into foreach loopsearchCriteria returning every result



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








-1















addfieldtofilter in magento2 behaving weirdly



I have code



 foreach($userIDs as $singleUserID) 
$userid=$singleUserID['user_id'];
var_dump($userid);//everytime for loop runs values changes 1,2,3
$userDetails = $this->userCollection ->addFieldToFilter('user_id',$userid);
var_dump($userDetails->getData());/* output: array('id'=>1,'user_id'=>1,'user_name'=>'a');
array('id'=>1,'user_id'=>1,'user_name'=>'a');
array('id'=>1,'user_id'=>1,'user_name'=>'a'); */



same code If I write with passing value then it gives correct data



 foreach($userIDs as $singleUserID) 
$userid=$singleUserID['user_id'];
var_dump($userid);//everytime for loop runs values changes 1,2,3

// If I am passing direct value 1 or 2 or 3. getting correct data

$userDetails = $this->userCollection->addFieldToFilter('user_id',3);
var_dump($userDetails->getData());/*output: array('id'=>1,'user_id'=>1,'user_name'=>'a'); for 1
array('id'=>2,'user_id'=>2,'user_name'=>'b'); for 2
array('id'=>3,'user_id'=>3,'user_name'=>'c'); for 3 */










share|improve this question






























    -1















    addfieldtofilter in magento2 behaving weirdly



    I have code



     foreach($userIDs as $singleUserID) 
    $userid=$singleUserID['user_id'];
    var_dump($userid);//everytime for loop runs values changes 1,2,3
    $userDetails = $this->userCollection ->addFieldToFilter('user_id',$userid);
    var_dump($userDetails->getData());/* output: array('id'=>1,'user_id'=>1,'user_name'=>'a');
    array('id'=>1,'user_id'=>1,'user_name'=>'a');
    array('id'=>1,'user_id'=>1,'user_name'=>'a'); */



    same code If I write with passing value then it gives correct data



     foreach($userIDs as $singleUserID) 
    $userid=$singleUserID['user_id'];
    var_dump($userid);//everytime for loop runs values changes 1,2,3

    // If I am passing direct value 1 or 2 or 3. getting correct data

    $userDetails = $this->userCollection->addFieldToFilter('user_id',3);
    var_dump($userDetails->getData());/*output: array('id'=>1,'user_id'=>1,'user_name'=>'a'); for 1
    array('id'=>2,'user_id'=>2,'user_name'=>'b'); for 2
    array('id'=>3,'user_id'=>3,'user_name'=>'c'); for 3 */










    share|improve this question


























      -1












      -1








      -1








      addfieldtofilter in magento2 behaving weirdly



      I have code



       foreach($userIDs as $singleUserID) 
      $userid=$singleUserID['user_id'];
      var_dump($userid);//everytime for loop runs values changes 1,2,3
      $userDetails = $this->userCollection ->addFieldToFilter('user_id',$userid);
      var_dump($userDetails->getData());/* output: array('id'=>1,'user_id'=>1,'user_name'=>'a');
      array('id'=>1,'user_id'=>1,'user_name'=>'a');
      array('id'=>1,'user_id'=>1,'user_name'=>'a'); */



      same code If I write with passing value then it gives correct data



       foreach($userIDs as $singleUserID) 
      $userid=$singleUserID['user_id'];
      var_dump($userid);//everytime for loop runs values changes 1,2,3

      // If I am passing direct value 1 or 2 or 3. getting correct data

      $userDetails = $this->userCollection->addFieldToFilter('user_id',3);
      var_dump($userDetails->getData());/*output: array('id'=>1,'user_id'=>1,'user_name'=>'a'); for 1
      array('id'=>2,'user_id'=>2,'user_name'=>'b'); for 2
      array('id'=>3,'user_id'=>3,'user_name'=>'c'); for 3 */










      share|improve this question
















      addfieldtofilter in magento2 behaving weirdly



      I have code



       foreach($userIDs as $singleUserID) 
      $userid=$singleUserID['user_id'];
      var_dump($userid);//everytime for loop runs values changes 1,2,3
      $userDetails = $this->userCollection ->addFieldToFilter('user_id',$userid);
      var_dump($userDetails->getData());/* output: array('id'=>1,'user_id'=>1,'user_name'=>'a');
      array('id'=>1,'user_id'=>1,'user_name'=>'a');
      array('id'=>1,'user_id'=>1,'user_name'=>'a'); */



      same code If I write with passing value then it gives correct data



       foreach($userIDs as $singleUserID) 
      $userid=$singleUserID['user_id'];
      var_dump($userid);//everytime for loop runs values changes 1,2,3

      // If I am passing direct value 1 or 2 or 3. getting correct data

      $userDetails = $this->userCollection->addFieldToFilter('user_id',3);
      var_dump($userDetails->getData());/*output: array('id'=>1,'user_id'=>1,'user_name'=>'a'); for 1
      array('id'=>2,'user_id'=>2,'user_name'=>'b'); for 2
      array('id'=>3,'user_id'=>3,'user_name'=>'c'); for 3 */







      magento2 magento-2.1 magento2.2 magento2.3 magento-2.0






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago







      Arshad Syed

















      asked 2 days ago









      Arshad SyedArshad Syed

      72




      72




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Now I able to get correct Data, I changed userCollection class to userCollectionfactory class




          use VendorMyModuleModelResourceModelUsersCollectionFactory as UserCollectionFactory;




          Every time foreach runs User id changes and addFieldToFilter gives correct user details w.r.t userID



           foreach($userIDs as $singleUserID) 
          $userid=$singleUserID['user_id'];
          var_dump($userid);//everytime values changes 1,2,3
          $userDetails = $this->userCollectionFactory->create() ->addFieldToFilter('user_id',$userid);
          var_dump($userDetails->getData());// output:
          array('id'=>1,'user_id'=>1,'user_name'=>'a');
          array('id'=>2,'user_id'=>2,'user_name'=>'b');
          array('id'=>3,'user_id'=>3,'user_name'=>'c');






          share|improve this answer

























          • Please do accept as an answer so others would use it

            – Prathap Gunasekaran
            2 days ago











          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%2f270431%2faddfieldtofilter-in-magento2-returning-same-data-everytime%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














          Now I able to get correct Data, I changed userCollection class to userCollectionfactory class




          use VendorMyModuleModelResourceModelUsersCollectionFactory as UserCollectionFactory;




          Every time foreach runs User id changes and addFieldToFilter gives correct user details w.r.t userID



           foreach($userIDs as $singleUserID) 
          $userid=$singleUserID['user_id'];
          var_dump($userid);//everytime values changes 1,2,3
          $userDetails = $this->userCollectionFactory->create() ->addFieldToFilter('user_id',$userid);
          var_dump($userDetails->getData());// output:
          array('id'=>1,'user_id'=>1,'user_name'=>'a');
          array('id'=>2,'user_id'=>2,'user_name'=>'b');
          array('id'=>3,'user_id'=>3,'user_name'=>'c');






          share|improve this answer

























          • Please do accept as an answer so others would use it

            – Prathap Gunasekaran
            2 days ago















          0














          Now I able to get correct Data, I changed userCollection class to userCollectionfactory class




          use VendorMyModuleModelResourceModelUsersCollectionFactory as UserCollectionFactory;




          Every time foreach runs User id changes and addFieldToFilter gives correct user details w.r.t userID



           foreach($userIDs as $singleUserID) 
          $userid=$singleUserID['user_id'];
          var_dump($userid);//everytime values changes 1,2,3
          $userDetails = $this->userCollectionFactory->create() ->addFieldToFilter('user_id',$userid);
          var_dump($userDetails->getData());// output:
          array('id'=>1,'user_id'=>1,'user_name'=>'a');
          array('id'=>2,'user_id'=>2,'user_name'=>'b');
          array('id'=>3,'user_id'=>3,'user_name'=>'c');






          share|improve this answer

























          • Please do accept as an answer so others would use it

            – Prathap Gunasekaran
            2 days ago













          0












          0








          0







          Now I able to get correct Data, I changed userCollection class to userCollectionfactory class




          use VendorMyModuleModelResourceModelUsersCollectionFactory as UserCollectionFactory;




          Every time foreach runs User id changes and addFieldToFilter gives correct user details w.r.t userID



           foreach($userIDs as $singleUserID) 
          $userid=$singleUserID['user_id'];
          var_dump($userid);//everytime values changes 1,2,3
          $userDetails = $this->userCollectionFactory->create() ->addFieldToFilter('user_id',$userid);
          var_dump($userDetails->getData());// output:
          array('id'=>1,'user_id'=>1,'user_name'=>'a');
          array('id'=>2,'user_id'=>2,'user_name'=>'b');
          array('id'=>3,'user_id'=>3,'user_name'=>'c');






          share|improve this answer















          Now I able to get correct Data, I changed userCollection class to userCollectionfactory class




          use VendorMyModuleModelResourceModelUsersCollectionFactory as UserCollectionFactory;




          Every time foreach runs User id changes and addFieldToFilter gives correct user details w.r.t userID



           foreach($userIDs as $singleUserID) 
          $userid=$singleUserID['user_id'];
          var_dump($userid);//everytime values changes 1,2,3
          $userDetails = $this->userCollectionFactory->create() ->addFieldToFilter('user_id',$userid);
          var_dump($userDetails->getData());// output:
          array('id'=>1,'user_id'=>1,'user_name'=>'a');
          array('id'=>2,'user_id'=>2,'user_name'=>'b');
          array('id'=>3,'user_id'=>3,'user_name'=>'c');







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          Arshad SyedArshad Syed

          72




          72












          • Please do accept as an answer so others would use it

            – Prathap Gunasekaran
            2 days ago

















          • Please do accept as an answer so others would use it

            – Prathap Gunasekaran
            2 days ago
















          Please do accept as an answer so others would use it

          – Prathap Gunasekaran
          2 days ago





          Please do accept as an answer so others would use it

          – Prathap Gunasekaran
          2 days ago

















          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%2f270431%2faddfieldtofilter-in-magento2-returning-same-data-everytime%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

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

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?