I am trying to create an virtual product programatically by using below code.When I execute this script from root of the store I am getting an error :
No date part in '' found.
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');
$product
->setWebsiteIds(array(1)) //website ID the product is assigned to, as an array
->setAttributeSetId(4) //ID of a attribute set named 'default'
->setTypeId('virtual') //product type
->setCreatedAt(strtotime('now')) //product creation time
->setSku('test') //SKU
->setName('Test Product') //product name
->setWeight(4.0000)
->setStatus(1) //product status (1 - enabled, 2 - disabled)
->setTaxClassId(0) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) //catalog and search visibility
->setPrice(0) //price in form 11.22
->setCost(0) //price in form 11.22
->setDescription('This is a long description')
->setShortDescription('This is a short description')
->setStockData(array(
'use_config_manage_stock' => 0, //'Use config settings' checkbox
'manage_stock'=>0, //manage stock
'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
'is_in_stock' => 1, //Stock Availability
'qty' => 999 //qty
)
);
try{
$product->save();
}catch(Exception $e){
Mage::log($e->getMessage());
}
Thank you in advance.