Posted over 6 years ago. Visible to the public.

Generate Test Products

I took this script from somewhere (sorry I forgot where!) but it didn't work for, so I fixed it up. Really basic, but useful, I used it to test pagination:

<?php require 'app/Mage.php'; Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); for ($i = 0; $i < 100; $i++) { Mage::getModel('catalog/product') ->setWebsiteIds(array(1)) ->setAttributeSetId(4) ->setTypeId('simple') ->setSku($i) ->setStatus(1) ->setTaxClassId(2) ->setVisibility(4) ->setName("Product Number $i") ->setDescription("This widget will give you years of trouble-free widgeting.") ->setShortDescription("High-end widget.") ->setPrice(99.99) ->setCategoryIds(array(152)) ->setWeight(1.0) ->setStockData(array( 'use_config_manage_stock' => 0, 'manage_stock' => 1, 'min_sale_qty' => 1, 'max_sale_qty' => 2, 'is_in_stock' => 1, 'qty' => 999 )) ->save(); };

Owner of this card:

Mike Whitby
Last edit:
over 6 years ago
by Mike Whitby
Posted by Mike Whitby to Magento
This website uses short-lived cookies to improve usability.
Accept or learn more