get attribute from children on 2000 products

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

I'm using a script to generate a csv file for another site. I am getting all products and on configurable ones I add in description some attributes.

Here is the code inside the function called on each configurable:

    $children_ids = $product->getTypeInstance()->getUsedProductIds();

    foreach($children_ids as $child_id){
        $child = Mage::getModel('catalog/product')->load($child_id);
        $attributeValue = $child->getAttributeText($attributeLabel);
        $child_qty = (int)$child->getStockItem()->getQty();
        $mage_size[$attributeValue] = $child_qty;
        $simple_qty += $child_qty;

I noticed that on large amount of products somehow the output suddenly stop without getting all. I tested with and without this code. Without I get as expected. I have set_time_limit(0); But no clue why my script terminate before getting information from all products. Any ideea whay may couse this behaviour?

It's not a proper solution but works on my script. I added

ini_set('memory_limit', '512M');

and works fine. I know 512 is way too much but just to be sure and to prevent that behaviour in the future when will be more products.

You would both have to increase the memory limit and PHP's execution time - magento is freakin' resource hungry.

I also generate product csv's with a custom script. I would recommend to run these kind of tasks from the command line.

`Reply Or Comment!
Please LogIn to Reply!