Skip to main content
added 902 characters in body
Source Link
B00MER
  • 8.3k
  • 2
  • 21
  • 49

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details: http://info.magento.com/rs/magentocommerce/images/Conquer_the_5_Most_Common_Magento_Coding_Issues_to_Optimize_Your_Site_for_Performance.pdf ***

*** EDIT *** Link fixed.

Also the reasoning you'll find in the Varien_Data_Collection class, as I mentioned if you were wanting to iterate over the collection, you're much better off using an iterator like the class does as it's a part of the framework's ORM. most likely the one off is the fact that when getSize is called the returned value is set with intval into an integer. As a 0 will = false, on conditions, etc. Take a look at getLastPageNumber and it will make sense.

As for a much better means of iterations without running out of memory on large collections is:

Mage::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array('productUpdateCallback'));```

Anyhow hopefully this explains it more.

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details: http://info.magento.com/rs/magentocommerce/images/Conquer_the_5_Most_Common_Magento_Coding_Issues_to_Optimize_Your_Site_for_Performance.pdf *** EDIT *** Link fixed.

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details: http://info.magento.com/rs/magentocommerce/images/Conquer_the_5_Most_Common_Magento_Coding_Issues_to_Optimize_Your_Site_for_Performance.pdf

*** EDIT *** Link fixed.

Also the reasoning you'll find in the Varien_Data_Collection class, as I mentioned if you were wanting to iterate over the collection, you're much better off using an iterator like the class does as it's a part of the framework's ORM. most likely the one off is the fact that when getSize is called the returned value is set with intval into an integer. As a 0 will = false, on conditions, etc. Take a look at getLastPageNumber and it will make sense.

As for a much better means of iterations without running out of memory on large collections is:

Mage::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array('productUpdateCallback'));```

Anyhow hopefully this explains it more.
added 26 characters in body
Source Link
B00MER
  • 8.3k
  • 2
  • 21
  • 49

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details: http://info.magento.com/rs/magentocommerce/images/Conquer_the_5_Most_Common_Magento_Coding_Issues_to_Optimize_Your_Site_for_Performance.pdf *** EDIT *** Link fixed.

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details:

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details: http://info.magento.com/rs/magentocommerce/images/Conquer_the_5_Most_Common_Magento_Coding_Issues_to_Optimize_Your_Site_for_Performance.pdf *** EDIT *** Link fixed.

Source Link
B00MER
  • 8.3k
  • 2
  • 21
  • 49

You should always use the ORM methods as using PHPs count or looping over the collection is bad practice. The reasoning is most likely off by one errors, which you'll most likely find buried some where in the framework such as varien collection.

Details: