There's around 18 000 products in a shop. When loading all in the front-end script it works. When loading them via cron(php_cli) the script times out/fails. The code:
$collection = Mage::getModel('catalog/product')->getCollection() ->setStoreId($storeId) ->addAttributeToSelect('name') ->addAttributeToSelect('url_path') ->addAttributeToFilter('visibility', 4) ->addAttributeToFilter('status', 1);
I thought that it's a memory/performance issue so I added
ini_set('memory_limit', '1024M'); on the top of the script and limited number of products to 20 with
->setPageSize(20)->setCurPage(1);. It still freezes when called by cron. I don't get any error report or exception.
Is it possible that 18k products are still loaded on the MySql side, despite adding page size limit, and make the server freeze?
Or does adding this limits the number of handled products to 20 on all levels of the application?
Which php/mysql settings shall I check/debug in this problem?
Sorry for a quite general question but it's difficult to choose the best approach in this situation.