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;
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
add a comment |
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
add a comment |
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
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
magento2 magento-2.1 magento2.2 magento2.3 magento-2.0
edited 2 days ago
Arshad Syed
asked 2 days ago
Arshad SyedArshad Syed
72
72
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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');
Please do accept as an answer so others would use it
– Prathap Gunasekaran
2 days ago
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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');
Please do accept as an answer so others would use it
– Prathap Gunasekaran
2 days ago
add a comment |
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');
Please do accept as an answer so others would use it
– Prathap Gunasekaran
2 days ago
add a comment |
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');
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');
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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