Get product collection based on entity_id in magento2Magento 2: to use or not to use the ObjectManager...

Intern applicant asking for compensation equivalent to that of permanent employee

awk + sum all numbers

The weather forecast

Which one of these password policies is more secure?

Cookies - Should the toggles be on?

Roman Numerals equation 1

What is the wife of a henpecked husband called?

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

Porting Linux to another platform requirements

Find some digits of factorial 17

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Caruana vs Carlsen game 10 (WCC) why not 18...Nxb6?

Why did other German political parties disband so fast when Hitler was appointed chancellor?

How can I deliver in-universe written lore to players without it being dry exposition?

Word or phrase for showing great skill at something WITHOUT formal training in it

What are "industrial chops"?

Strange Sign on Lab Door

How can my powered armor quickly replace its ceramic plates?

Can a hotel cancel a confirmed reservation?

Normalization for two bulk RNA-Seq samples to enable reliable fold-change estimation between genes

Digits in an algebraic irrational number

What is the purpose of easy combat scenarios that don't need resource expenditure?

One Half of Ten; A Riddle

Can I string the D&D Starter Set campaign into another module, keeping the same characters?



Get product collection based on entity_id in magento2


Magento 2: to use or not to use the ObjectManager directly?Update behaviour in csv not working as expectedCreate magento pagination in custom product collection inside phtml fileProducts from a category plus any children and get category ID for conditions from collectionLayered navigation for custom collection on custom page - magento2Model Override issue in magento 2Left layered navigation for the custom product collection in the custom pageMagento 2 get custom module data in theme phtmlMagento 2 - Get Swatch Image based on swatch labelCategory order does not work, always sort by the entity_id descaddFieldtofilter array not readingSKU Report for null attribute values













0















How to Create product collection with filter based on entity_id in Magento 2?



I tried below:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->getCollection()
->addFieldToFilter('entity_id', $ProductId);

// Tried this too
/*
$getId=$model->getCollection()->create()
->addAttributeToSelect('*')
->addFieldToFilter('entity_id',$ProductId); */
if ($getId = '') {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}


I am not getting the collection! nor the id is saved



My id should no be saved if already present in DB.










share|improve this question
















bumped to the homepage by Community 13 mins ago


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











  • 1





    Possible duplicate of Update behaviour in csv not working as expected

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:27
















0















How to Create product collection with filter based on entity_id in Magento 2?



I tried below:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->getCollection()
->addFieldToFilter('entity_id', $ProductId);

// Tried this too
/*
$getId=$model->getCollection()->create()
->addAttributeToSelect('*')
->addFieldToFilter('entity_id',$ProductId); */
if ($getId = '') {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}


I am not getting the collection! nor the id is saved



My id should no be saved if already present in DB.










share|improve this question
















bumped to the homepage by Community 13 mins ago


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











  • 1





    Possible duplicate of Update behaviour in csv not working as expected

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:27














0












0








0








How to Create product collection with filter based on entity_id in Magento 2?



I tried below:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->getCollection()
->addFieldToFilter('entity_id', $ProductId);

// Tried this too
/*
$getId=$model->getCollection()->create()
->addAttributeToSelect('*')
->addFieldToFilter('entity_id',$ProductId); */
if ($getId = '') {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}


I am not getting the collection! nor the id is saved



My id should no be saved if already present in DB.










share|improve this question
















How to Create product collection with filter based on entity_id in Magento 2?



I tried below:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->getCollection()
->addFieldToFilter('entity_id', $ProductId);

// Tried this too
/*
$getId=$model->getCollection()->create()
->addAttributeToSelect('*')
->addFieldToFilter('entity_id',$ProductId); */
if ($getId = '') {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}


I am not getting the collection! nor the id is saved



My id should no be saved if already present in DB.







magento2 product collection tags






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 5 '16 at 10:21









7ochem

5,77293768




5,77293768










asked Aug 5 '16 at 9:51









SushivamSushivam

1,25521446




1,25521446





bumped to the homepage by Community 13 mins ago


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 13 mins ago


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










  • 1





    Possible duplicate of Update behaviour in csv not working as expected

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:27














  • 1





    Possible duplicate of Update behaviour in csv not working as expected

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:27








1




1





Possible duplicate of Update behaviour in csv not working as expected

– Siarhey Uchukhlebau
Aug 5 '16 at 11:27





Possible duplicate of Update behaviour in csv not working as expected

– Siarhey Uchukhlebau
Aug 5 '16 at 11:27










1 Answer
1






active

oldest

votes


















0














If the entity_id is key of the model, try this:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->load($ProductId);

if (!$getId->getId()) {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}





share|improve this answer
























  • Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

    – Sushivam
    Aug 5 '16 at 11:11











  • I get the ids correctly if i log $ProductId , but saving is the issue!

    – Sushivam
    Aug 5 '16 at 11:12











  • Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

    – Anna Völkl
    Aug 5 '16 at 11:15











  • @AnnaVölkl I know, but this is the source code from the question

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:16











  • @SachinS Could you update the question with full code?

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:18











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%2f130125%2fget-product-collection-based-on-entity-id-in-magento2%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














If the entity_id is key of the model, try this:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->load($ProductId);

if (!$getId->getId()) {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}





share|improve this answer
























  • Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

    – Sushivam
    Aug 5 '16 at 11:11











  • I get the ids correctly if i log $ProductId , but saving is the issue!

    – Sushivam
    Aug 5 '16 at 11:12











  • Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

    – Anna Völkl
    Aug 5 '16 at 11:15











  • @AnnaVölkl I know, but this is the source code from the question

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:16











  • @SachinS Could you update the question with full code?

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:18
















0














If the entity_id is key of the model, try this:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->load($ProductId);

if (!$getId->getId()) {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}





share|improve this answer
























  • Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

    – Sushivam
    Aug 5 '16 at 11:11











  • I get the ids correctly if i log $ProductId , but saving is the issue!

    – Sushivam
    Aug 5 '16 at 11:12











  • Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

    – Anna Völkl
    Aug 5 '16 at 11:15











  • @AnnaVölkl I know, but this is the source code from the question

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:16











  • @SachinS Could you update the question with full code?

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:18














0












0








0







If the entity_id is key of the model, try this:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->load($ProductId);

if (!$getId->getId()) {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}





share|improve this answer













If the entity_id is key of the model, try this:



$model = $this->_objectManager->create('VendorMOduleModelQueue');
$ProductId = $this->skuProcessor->getNewSku($rowSku)['entity_id'];
$getId = $tagmodel->load($ProductId);

if (!$getId->getId()) {
$tagmodel->setEntityId($ProductId);
$tagmodel->save();
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 5 '16 at 10:21









Siarhey UchukhlebauSiarhey Uchukhlebau

9,80192858




9,80192858













  • Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

    – Sushivam
    Aug 5 '16 at 11:11











  • I get the ids correctly if i log $ProductId , but saving is the issue!

    – Sushivam
    Aug 5 '16 at 11:12











  • Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

    – Anna Völkl
    Aug 5 '16 at 11:15











  • @AnnaVölkl I know, but this is the source code from the question

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:16











  • @SachinS Could you update the question with full code?

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:18



















  • Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

    – Sushivam
    Aug 5 '16 at 11:11











  • I get the ids correctly if i log $ProductId , but saving is the issue!

    – Sushivam
    Aug 5 '16 at 11:12











  • Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

    – Anna Völkl
    Aug 5 '16 at 11:15











  • @AnnaVölkl I know, but this is the source code from the question

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:16











  • @SachinS Could you update the question with full code?

    – Siarhey Uchukhlebau
    Aug 5 '16 at 11:18

















Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

– Sushivam
Aug 5 '16 at 11:11





Siarhey, i m trying to add only those product ids which are updated via csv import. For eg i have 2 product ids 1 and 2... i updated only one id and when i upload only that id which i updated should be saved in table

– Sushivam
Aug 5 '16 at 11:11













I get the ids correctly if i log $ProductId , but saving is the issue!

– Sushivam
Aug 5 '16 at 11:12





I get the ids correctly if i log $ProductId , but saving is the issue!

– Sushivam
Aug 5 '16 at 11:12













Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

– Anna Völkl
Aug 5 '16 at 11:15





Better not use the objectManager this way, check out: magento.stackexchange.com/questions/117098/…

– Anna Völkl
Aug 5 '16 at 11:15













@AnnaVölkl I know, but this is the source code from the question

– Siarhey Uchukhlebau
Aug 5 '16 at 11:16





@AnnaVölkl I know, but this is the source code from the question

– Siarhey Uchukhlebau
Aug 5 '16 at 11:16













@SachinS Could you update the question with full code?

– Siarhey Uchukhlebau
Aug 5 '16 at 11:18





@SachinS Could you update the question with full code?

– Siarhey Uchukhlebau
Aug 5 '16 at 11:18


















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%2f130125%2fget-product-collection-based-on-entity-id-in-magento2%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

迭戈·戈丁...

A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...