<?php //$product = Mage::getModel(‘catalog/product’);$product = new Mage_Catalog_Model_Product(); // Build the product$product->setSku(‘sku’);$product->setAttributeSetId(‘Attribute_id’);$product->setTypeId(‘simple’);$product->setName(‘product name’);$product->setCategoryIds(array(9)); # category id’s$product->setWebsiteIDs(array(1)); # Website id$product->setDescription(‘Long description’);$product->setShortDescription(‘Short description’);$product->setPrice(19.99); # producte price # Custom created and assigned attributes$product->setHeight(‘custom_attribute1_val’);$product->setWidth(‘custom_attribute2_val’);$product->setDepth(‘custom_attribute3_val’);$product->setType(‘custom_attribute4_val’); //Default Magento attribute$product->setWeight(2.0000); $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);$product->setStatus(1);$product->setTaxClassId(0); # My default tax class$product->setStockData(array( ‘is_in_stock’ => 1, ‘qty’ => 20)); $product->setCreatedAt(strtotime(‘now’)); try { $product->save();}catch (Exception $ex) ...
Read More
Recent Comments