I am validating an extension using ECG Sniffs and I get a warning 'getFirstItem does not limit the result of collection load to one item
Here is how I am trying to get default configured website.
$websites = Mage::getModel('core/website')
->getCollection()
->addFieldToFilter('is_default', 1);
$website = $websites->getFirstItem();
Here I try to replace $websites->getFirstItem() with $websites->getSelect()->limit() as per a suggestion but it gives another warning Data access method LIMIT detected outside of Resource Model
Can anybody please help me how to fix the warning?
P.S. I am neither magento nor PHP developer.
$websites->getFirstItem(). Just add$websites->getSelect()->limit(1)before. Btw ... the warning will still appear. If you've limit the query to 1, you can usegetLastItem()instead. – sv3n Dec 12 '17 at 10:52$websites->setPageSize(1, 1)->getLastItem()– Amit Patel Dec 12 '17 at 11:23Data load getParentIdsByChild() method detected in loopwarning. I am fetching parent sku for each product in loop. Here is a reference question https://stackoverflow.com/a/11481143/517483. Any idea? – Amit Patel Dec 12 '17 at 12:10