This snippet works fine except that it returns a different set of product collection, mainly due to is anchor attribute:

$category = Mage::getModel('catalog/category')->load(1371);
$collection = Mage::getModel('catalog/product')

The snippet above returns the complete products including the child category products. However, when running through cron, it returns only a small amount of items. I could simulate what the cron is getting by defining:


I want to get the collection that includes the sub category products. How can I achieve this?

1 Answer 1


Try This code

error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
ini_set('display_errors', 1);
ini_set('memory_limit', '600M');
ini_set('max_execution_time', 1800);
    $_productCollection = Mage::getModel('catalog/category')->load(48)
     ->addAttributeToFilter('visibility', 4);
     foreach($_productCollection as $product){



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.