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

          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