require_once 'app/Mage.php';
Mage::app();
// instatiate Product
$product = Mage::getModel('catalog/product');
$product->setWebsiteIds(array(1));
$product->setSku('rand-sku-' . rand());
$product->setPrice(rand(100,2000));
$product->setAttributeSetId(4);
$product->setCategoryIds(array(3));
$product->setType('Simple Product');
$product->setName('Product Name'.rand(1,200000));
$product->setDescription('The Product Description');
$product->setShortDescription('Brief Description');
$product->setStatus(1);
$product->setTaxClassId('2');
$product->setWeight(0);
$product->setCreatedAt(strtotime('now'));
/* ADDITIONAL OPTIONS
$product->setCost();
$product->setInDepth();
$product->setKeywords();
*/
$product->save();
// "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->loadByProduct($product->getId());
$stockItem->setData('is_in_stock', 1);
$stockItem->save();
header("Location: /checkout/cart/add/product/".$product->getId()."/);
Wednesday, July 16, 2014
11:59 PM
Magento How to add new products
MR: EDITOR
A blogger
I am passionate blogger cum B.Tech. Computer engineering graduate. I love writing blog post. I spend my free time in writing blog post that will useful to everyone (including me). I have had some success making money blogging and want to help others do the same. I just figured that by creating a great and free resource a lot of links would follow – and they have. Some people ask me how they can repay me – which is not necessary - but for those wanting to show their appreciation, I just say linking to the article from their blog is the best compensation I could receive. Thanks for reading!
Related Posts
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Thanks for commenting. I will Reply you soon