Thursday, 16 June 2011

Display Image in Magento From Skin Folder

<img src="<?php echo $this->getSkinUrl('images/sitelogo.jpg');?>" 
alt="sitename" />

Magento Check if Customer Loged in or Not

<?php
$_customer = Mage::getSingleton('customer/session')->isLoggedIn();

if ($_customer) {
// do stuff
}
?>

Remove SID from Magento URL

Open file "app\code\core\Mage\Core\Model\Session\Abstract.php"
find this code 'protected $_skipSessionIdFlag = true;'
replace it with this 'protected $_skipSessionIdFlag = false,'

Get The productID On The Frontend In Magento

<?php echo $_helper->productAttribute($_product$_product->getId(), \'id\'?>

Wednesday, 15 June 2011

Displaying Currency in magento with php number_format()

<?php echo number_format($_product->getFinalPrice(),2);?>

Get productID from specific order in Magento

$order = Mage::getModel('sales/order')->load($order_id);
$items = $order->getAllItems();
$itemcount=count($items);
$name=array();
$unitPrice=array();
$sku=array();
$ids=array();
$qty=array();
foreach ($items as $itemId => $item)
{
    $name[] = $item->getName();
    $unitPrice[]=$item->getPrice();
    $sku[]=$item->getSku();
    $ids[]=$item->getProductId();
    $qty[]=$item->getQtyToInvoice();
}

base url in magento

we can get the base url of magento site with the code below, 
just place this code anywhere in .phtml file and you will 
get the base url of your magento site.
<?php echo Mage::getBaseUrl(); ?>