Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Magento How to add new products

require_once 'app/Mage.php';
// instatiate Product
$product = Mage::getModel('catalog/product');
$product->setSku('rand-sku-' . rand());
$product->setType('Simple Product');
$product->setName('Product Name'.rand(1,200000));
$product->setDescription('The Product Description');
$product->setShortDescription('Brief Description');
// "Stock Item" still required regardless of whether inventory
// control is used, or stock item error given at checkout!
$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->setData('is_in_stock', 1);
header("Location: /checkout/cart/add/product/".$product->getId()."/); 

One response to “Magento How to add new products

  1. Tilly 13/10/2013 at 6:31 AM

    This is a really good tip especially to those new to the blogosphere.

    Short but very precise information… Many thanks for sharing this
    one. A must read post!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: