Magento 2 , How to avaid load() in loop? The Next CEO of Stack OverflowIgnoring unused...
Can the Reverse Gravity spell affect the Meteor Swarm spell?
How can I quit an app using Terminal?
If I blow insulation everywhere in my attic except the door trap, will heat escape through it?
Why does C# sound extremely flat when saxophone is tuned to G?
Inappropriate reference requests from Journal reviewers
Too much space between section and text in a twocolumn document
Are there languages with no euphemisms?
How to Reset Passwords on Multiple Websites Easily?
Grabbing quick drinks
What's the point of interval inversion?
India just shot down a satellite from the ground. At what altitude range is the resulting debris field?
What is the point of a new vote on May's deal when the indicative votes suggest she will not win?
Term for the "extreme-extension" version of a straw man fallacy?
Is it okay to store user locations?
Why here is plural "We went to the movies last night."
How can I open an app using Terminal?
Need some help with wall behind rangetop
How did people program for Consoles with multiple CPUs?
When Does an Atlas Uniquely Define a Manifold?
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
How to be diplomatic in refusing to write code that breaches the privacy of our users
Why did we only see the N-1 starfighters in one film?
How do we know the LHC results are robust?
What happens if you roll doubles 3 times then land on "Go to jail?"
Magento 2 , How to avaid load() in loop?
The Next CEO of Stack OverflowIgnoring unused parameter with code snifferAvoiding save in a loop in mass actionHow to tackle with multiple time product load in magento?Controller not loading Grid container Error: Class 'Mage_Reviewmycompany_Helper_DataMagento 2 get Parameters in the URLMagento 2: Model edit form fields not loadingMass delete action in one step not in loop magento 2MEQP Gives a Warning : Data load getFirstItem() method detected in loopCreating new form in Magento 2 always getting errorDisable inline edit in ui listing
I have created the custom module with an inline edit in the grid, all working fine. once I have running phpsniffer with the EcgM2 standard, I get this warning:
Model LSD method load() detected in loop
magento2 controllers optimization
add a comment |
I have created the custom module with an inline edit in the grid, all working fine. once I have running phpsniffer with the EcgM2 standard, I get this warning:
Model LSD method load() detected in loop
magento2 controllers optimization
refer this link github.com/magento/magento2/issues/10380
– ABHISHEK TRIPATHI
Feb 19 '18 at 13:13
add a comment |
I have created the custom module with an inline edit in the grid, all working fine. once I have running phpsniffer with the EcgM2 standard, I get this warning:
Model LSD method load() detected in loop
magento2 controllers optimization
I have created the custom module with an inline edit in the grid, all working fine. once I have running phpsniffer with the EcgM2 standard, I get this warning:
Model LSD method load() detected in loop
magento2 controllers optimization
magento2 controllers optimization
edited 22 mins ago
Teja Bhagavan Kollepara
3,01241949
3,01241949
asked Feb 19 '18 at 13:10
user53836
refer this link github.com/magento/magento2/issues/10380
– ABHISHEK TRIPATHI
Feb 19 '18 at 13:13
add a comment |
refer this link github.com/magento/magento2/issues/10380
– ABHISHEK TRIPATHI
Feb 19 '18 at 13:13
refer this link github.com/magento/magento2/issues/10380
– ABHISHEK TRIPATHI
Feb 19 '18 at 13:13
refer this link github.com/magento/magento2/issues/10380
– ABHISHEK TRIPATHI
Feb 19 '18 at 13:13
add a comment |
1 Answer
1
active
oldest
votes
Use collection and filters to get list of models u need.
Sample below:
/** @var MagentoCatalogModelResourceModelProductCollectionFactory */
protected $collectionFactory;
public function __construct(
MagentoCatalogModelResourceModelProductCollectionFactory $collectionFactory
) {
$this->collectionFactory = $collectionFactory;
}
public function yourMethod()
{
// Use factory to create a new product collection
$productCollection = $this->collectionFactory->create();
/** Apply filters here */
$productCollection->addAttributeToSelect('*');
// Don't have to do this
// $productCollection->load();
foreach ($productCollection as $product){
echo 'Name = '.$product->getName().'<br>';
}
}
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
1
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
1
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
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%2f214086%2fmagento-2-how-to-avaid-load-in-loop%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
Use collection and filters to get list of models u need.
Sample below:
/** @var MagentoCatalogModelResourceModelProductCollectionFactory */
protected $collectionFactory;
public function __construct(
MagentoCatalogModelResourceModelProductCollectionFactory $collectionFactory
) {
$this->collectionFactory = $collectionFactory;
}
public function yourMethod()
{
// Use factory to create a new product collection
$productCollection = $this->collectionFactory->create();
/** Apply filters here */
$productCollection->addAttributeToSelect('*');
// Don't have to do this
// $productCollection->load();
foreach ($productCollection as $product){
echo 'Name = '.$product->getName().'<br>';
}
}
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
1
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
1
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
add a comment |
Use collection and filters to get list of models u need.
Sample below:
/** @var MagentoCatalogModelResourceModelProductCollectionFactory */
protected $collectionFactory;
public function __construct(
MagentoCatalogModelResourceModelProductCollectionFactory $collectionFactory
) {
$this->collectionFactory = $collectionFactory;
}
public function yourMethod()
{
// Use factory to create a new product collection
$productCollection = $this->collectionFactory->create();
/** Apply filters here */
$productCollection->addAttributeToSelect('*');
// Don't have to do this
// $productCollection->load();
foreach ($productCollection as $product){
echo 'Name = '.$product->getName().'<br>';
}
}
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
1
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
1
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
add a comment |
Use collection and filters to get list of models u need.
Sample below:
/** @var MagentoCatalogModelResourceModelProductCollectionFactory */
protected $collectionFactory;
public function __construct(
MagentoCatalogModelResourceModelProductCollectionFactory $collectionFactory
) {
$this->collectionFactory = $collectionFactory;
}
public function yourMethod()
{
// Use factory to create a new product collection
$productCollection = $this->collectionFactory->create();
/** Apply filters here */
$productCollection->addAttributeToSelect('*');
// Don't have to do this
// $productCollection->load();
foreach ($productCollection as $product){
echo 'Name = '.$product->getName().'<br>';
}
}
Use collection and filters to get list of models u need.
Sample below:
/** @var MagentoCatalogModelResourceModelProductCollectionFactory */
protected $collectionFactory;
public function __construct(
MagentoCatalogModelResourceModelProductCollectionFactory $collectionFactory
) {
$this->collectionFactory = $collectionFactory;
}
public function yourMethod()
{
// Use factory to create a new product collection
$productCollection = $this->collectionFactory->create();
/** Apply filters here */
$productCollection->addAttributeToSelect('*');
// Don't have to do this
// $productCollection->load();
foreach ($productCollection as $product){
echo 'Name = '.$product->getName().'<br>';
}
}
edited Oct 25 '18 at 11:49
answered Oct 25 '18 at 10:27
Wojciech KaWojciech Ka
14514
14514
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
1
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
1
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
add a comment |
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
1
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
1
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
– Rama Chandran M
Oct 25 '18 at 10:56
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
@RamaChandranM its short, but still an answer ...
– sv3n
Oct 25 '18 at 11:07
1
1
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
@RamaChandranM I corrected my answer a little bit
– Wojciech Ka
Oct 25 '18 at 11:50
1
1
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
Thanks @sv3n, Thanks for updated ans Wqojciech. Some detail explain will help other.
– Rama Chandran M
Oct 25 '18 at 18:20
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%2f214086%2fmagento-2-how-to-avaid-load-in-loop%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
refer this link github.com/magento/magento2/issues/10380
– ABHISHEK TRIPATHI
Feb 19 '18 at 13:13