Magento Set, Retrieve and Unset Session Variables

Posted: April 20th, 2011 | Author: | Filed under: magento | 3 Comments »

To set a Magento session variable:

$myValue = 'Hello World';
Mage::getSingleton('core/session')->setMyValue($myValue);

To Retrieve:

$myValue = '';
$myValue=Mage::getSingleton('core/session')->getMyValue();

To Unset:

Mage::getSingleton('core/session')->unsMyValue();

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


Add Linkshare Pixel To Magento

Posted: April 19th, 2011 | Author: | Filed under: magento, php, web | No Comments »

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

<?php
 
$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="https://track.linksynergy.com/ep?mid=xxxx&ord=<?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 .


Magento: Load Javascript On One Page Checkout

Posted: March 18th, 2011 | Author: | Filed under: magento | 1 Comment »

Add this to page.xml

<checkout_onepage_index>
    <reference name="head">  
         <action method="addItem"><type>skin_js</type><name>js/myscript.js</name></action>
    </reference>
</checkout_onepage_index>

The type ‘System.TimeZoneInfo’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

Posted: December 10th, 2010 | Author: | Filed under: rando | 4 Comments »

To fix the error in C# project:
The type ‘System.TimeZoneInfo’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

Download and install .Net Framework version 3.5 (If you don’t already have that version).
After installation go into your project and add a reference to System.Core (.Net Tab), make sure the version is 3.5