Create Global Function In Magento

This code will allow you to add a function that can be called from anywhere within Magento. It extends the helper class

1) Create a file named ‘Mycode.xml’ and copy it to app/etc/modules/ – it should look like this:

<?xml version="1.0"?>

2) Create the directory
and then create a file named ‘config.xml’
In it copy:

<?xml version="1.0"?>

3) Create the directory
and then create a file named ‘Data.php’
In it copy:

class Mycode_Function_Helper_Data extends Mage_Core_Helper_Abstract
	public function test(){
	return 'works';

You can now call this function like so

		 echo Mage::helper('function')->test();

Magento Set, Retrieve and Unset Session Variables

To set a Magento session variable:

$myValue = 'Hello World';

To Retrieve:

$myValue = '';

To Unset:


Note that ‘MyValue’ can be any text you want but ‘set’, ‘get’ and ‘uns’ prefixes are required.

Add Linkshare Pixel To Magento

Add this code to:
\app\design\frontend\enterprise\<your theme>\template\checkout\success.phtml

$order_id = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getModel('sales/order')->load($order_id);
$_totalData = $order->getData();
/*linkshare vars*/
$skus = array();
$qtys = array();
$amounts = array();
foreach ($order->getAllItems() as $item) {
        $skus[$item->getProductId()] = $item->getSku();
	$names[$item->getProductId()] = rawurlencode($item->getName());
	$qtys[$item->getProductId()] = $item->getQtyOrdered() * 1;
	$amounts[$item->getProductId()] = $item->getRowTotal() * 100;	
$order_id = $_totalData['increment_id'];
$skuspipe = implode("|", $skus);
$namespipe = implode("|", $names);
$qtyspipe = implode("|", $qtys);
$amountspipe = implode("|", $amounts);
<img src="<?php echo $order_id ?>
&skulist=<?php echo $skuspipe ?>&qlist=<?php echo $qtyspipe ?>&amtlist=
<?php echo $amountspipe ?>&cur=USD&namelist=<?php echo $namespipe ?>">

Make sure to replace ‘xxxx’ with your own Merchant Id number

Code modified/corrected from this post .