<?php
require_once ‘app/Mage.php’;

$app = Mage::app();
?>

<?php

$product = Mage::getModel(‘catalog/product’);

$product->setSku(“ABC123hhsgfsgg”);
$product->setName(“Type 7 Widget”);
$product->setDescription(“This widget will give you years of trouble-free widgeting.”);
$product->setShortDescription(“High-end widget.”);
$product->setPrice(70.50);
$product->setTypeId(‘simple’);
$product->setAttributeSetId(4); // need to look this up
$product->setCategoryIds(“1,11”) or die(mysql_error()); // need to look these up
$product->setWeight(1.0);
$product->setTaxClassId(2); // taxable goods
$product->setVisibility(4); // catalog, search
$product->setStatus(1); // enabled

$stockData = $product->getStockData();
$stockData[‘qty’] = 10;
$stockData[‘is_in_stock’] = 1;
$stockData[‘manage_stock’] = 1;
$stockData[‘use_config_manage_stock’] = 0;
$product->setStockData($stockData);

// assign product to the default website
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));

$product->save();

echo “product saved…”;

?>

[twitter-follow screen_name='nirav1188']

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *