Get product collection based on entity_id in magento2
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
bumped to the homepage by Community♦ 14 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
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
bumped to the homepage by Community♦ 14 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
add a comment |
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
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
magento2 product collection tags
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♦ 14 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♦ 14 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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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();
}
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
|
show 4 more comments
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%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
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();
}
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
|
show 4 more comments
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();
}
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
|
show 4 more comments
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();
}
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();
}
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
|
show 4 more comments
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
|
show 4 more comments
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%2f130125%2fget-product-collection-based-on-entity-id-in-magento2%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
1
Possible duplicate of Update behaviour in csv not working as expected
– Siarhey Uchukhlebau
Aug 5 '16 at 11:27