Product stock is not saved when creating a product programmatically
This is a working example wich i use:
$product = Mage::getModel('catalog/product');
$product->setWebsiteIds(array(1));
$product->setTypeId('simple');
$product->setName('name');
$product->setDescription('xyz');
$product->setShortDescription(' ');
$product->setStatus(1);
$product->setTaxClassId(1);
$product->setWeight(0);
$product->setCreatedAt(strtotime('now'));
$product->setManufacturer(1);
$product->setAttributeSetId(1);
$product->setSku('sku');
$product->setPrice(5);
$product->setVisibility(1);
$product->save();
After saving the product create stock item:
$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->assignProduct($product);
$stockItem->setData('is_in_stock', 1);
$stockItem->setData('stock_id', 1);
$stockItem->setData('store_id', 1);
$stockItem->setData('manage_stock', 1);
$stockItem->setData('use_config_manage_stock', 0);
$stockItem->setData('min_sale_qty', 1);
$stockItem->setData('use_config_min_sale_qty', 0);
$stockItem->setData('max_sale_qty', 1000);
$stockItem->setData('use_config_max_sale_qty', 0);
$stockItem->setData('qty', 10);
$stockItem->save();