Created
July 11, 2013 18:05
-
-
Save rgranadino/5977733 to your computer and use it in GitHub Desktop.
install dummy rice and beans product in magento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
require 'app/Mage.php'; | |
if (!Mage::isInstalled()) { | |
echo "Application is not installed yet, please complete install wizard first."; | |
exit(1); | |
} | |
$baseDir = getcwd(); | |
//not sure if this is necessary, ported over from cron.php script | |
$_SERVER['SCRIPT_NAME'] = $baseDir.'/index.php'; | |
$_SERVER['SCRIPT_FILENAME'] = $baseDir.'/index.php'; | |
Mage::app()->setUseSessionInUrl(false); | |
try { | |
ini_set('display_errors', 1); | |
ini_set('log_errors', 1); | |
if (!empty($_SERVER['HOME'])) { | |
ini_set('error_log', $_SERVER['HOME'] . '/imc.log'); | |
} | |
error_reporting(E_ALL); | |
Mage::app('','store'); | |
/* @product Mage_Catalog_Model_Product */ | |
$defaultAttributeSetId = 4; | |
$product = Mage::getModel('catalog/product'); | |
$product->setSku('rice'); | |
$product->setAttributeSetId($defaultAttributeSetId); | |
$product->setTypeId('simple'); | |
$product->setName('rice'); | |
$product->setWebsiteIDs(array(1)); | |
$product->setDescription('Full description here'); | |
$product->setShortDescription('Short description here'); | |
$product->setPrice(13.37); | |
//Default Magento attribute | |
$product->setWeight(4.0000); | |
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); | |
$product->setStatus(1); | |
$product->setTaxClassId(2); # My default tax class | |
$product->setStockData(array('is_in_stock' => 1,'qty' => 1337)); | |
$product->setCreatedAt(strtotime('now')); | |
$product->save(); | |
//second test product | |
$product = Mage::getModel('catalog/product'); | |
$product->setSku('beans'); | |
$product->setAttributeSetId($defaultAttributeSetId); | |
$product->setTypeId('simple'); | |
$product->setName('rice'); | |
$product->setWebsiteIDs(array(1)); | |
$product->setDescription('Full description here'); | |
$product->setShortDescription('Short description here'); | |
$product->setPrice(133.37); | |
//Default Magento attribute | |
$product->setWeight(4.0000); | |
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); | |
$product->setStatus(1); | |
$product->setTaxClassId(2); # My default tax class | |
$product->setStockData(array('is_in_stock' => 1,'qty' => 1337)); | |
$product->setCreatedAt(strtotime('now')); | |
$product->save(); | |
} catch (Exception $e) { | |
Mage::printException($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment