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
Term for the "extreme-extension" version of a straw man fallacy?
How to write papers efficiently when English isn't my first language?
Text adventure game code
Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?
How to be diplomatic in refusing to write code that breaches the privacy of our users
How do we know the LHC results are robust?
When Does an Atlas Uniquely Define a Manifold?
How to make a software documentation "officially" citable?
What is the purpose of the Evocation wizard's Potent Cantrip feature?
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
Why do remote companies require working in the US?
% symbol leads to superlong (forever?) compilations
Is it safe to use c_str() on a temporary string?
How did people program for Consoles with multiple CPUs?
Return the Closest Prime Number
Whats the best way to handle refactoring a big file?
Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis
What happens if you roll doubles 3 times then land on "Go to jail?"
How can I open an app using Terminal?
Why is there a PLL in CPU?
Can a single photon have an energy density?
Should I tutor a student who I know has cheated on their homework?
Why does standard notation not preserve intervals (visually)
Visit to the USA with ESTA approved before trip to Iran
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 44 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