- partychat
- pkircher
- kasn
- madcad
- Nate Flint
Welcome to Snippi.net. Place to share Magento code snippets.
Feel free to register and submit your own code snippets. Making so will hopefully help speed up collective community learning process with Magento eCommerce platform.
<?php
require_once 'app/Mage.php';
umask(0);
/* not Mage::run(); */
Mage::app('admin');
$product = Mage::getModel('catalog/product');
$productId = $product->getIdBySku("testproduct");
$product->load($productId);
$copy = $product->duplicate();
$id_copy = $copy->getId();
echo $id_copy;
$copy = Mage::getModel('catalog/product')->load($id_copy);
$co
/**
* Indents a string to given deep
*
* @param string $string string to indent
* @param int $level depp of the indent
*
* @return string
*/
function indentString($string, $level)
{
while($level) {
$level--;
echo " ";
}
echo $string;
}
/**
* dumps an Array as PHP code
*
* @param array $array array to dump
* @param int $level ind
//External script - Load magento framework
require_once("../app/Mage.php");
Mage::app();
/* function for adding new node to xml file */
function Add_NewDocElement($root, $parent, $name, $value){
$parent->appendChild($root->createElement($name))->appendChild($root->createTextNode($value));
}
#creating new xml-document
$dom = new DomDoc
// load order
$order = Mage::getModel('sales/order')->load($orderId);
// set store and locale according to order store
Mage::app()->setCurrentStore($order->getStoreId());
Mage::app()->getLocale()->emulate($order->getStoreId());
// create invoice and send email
if ($order->canInvoice()) {
$invoice = $order->prepareInvoice();
$invoice->register();
$invoice->setEmailSent(true