10/28/2010

How to add or install a new language in Magento

Installing a second language in magento or Adding a new language in Magento is very easy.

I am describing it with an example.Installing the French language
For this I search extension in magento Commerce for France language and copied the extension (magento-community/Locale_Mage_community_fr_FR). Now I logged in to magento connect manager of my website and installed this extension. Then I Create 2 store view one is for English and another one is for French .Be sure to use en in the code field for English Store view and Fr for France store view. Now go to System->configuration, from Current Configuration Scope: select your storeview (i select France) .then click on Locale Options Tab. From locale select Frech(France) and save store view. Do same for English and select United kingdom.Now save Config and refresh the cache of your site to see the effect.

10/27/2010

How to remove parent category path from sub category url in Magento

Go to app/code/core/Mage/Catalog/Model/

Open Url.php and go to line no 632 and comment(//) the below line

If you are using Magento 1.5 then please go to line number 797 instead of 632

//if (null === $parentPath) {
//$parentPath = $this->getResource()->getCategoryParentPath($category);
//}
//elseif ($parentPath == '/') {
$parentPath = ''; //('Don't comment it')
//}

Now save and upload it.

Now login to admin panel of your site then go to System->Config->Index Management and click on select all then select Reindex Data from the Action Dropdown then click on submit.

10/26/2010

How to set or change Page title of a custom module in magento

If you are making a new Module in magento then you must set your page title. To set Page title in your module write the code below inside your all action of your module Design XML.
You can find your module xml inside
app/design/frontend/default/yourtheme/layout

<reference name="head">
<action method="setTitle"><title> Your Page Title </title></action>
</reference>

10/25/2010

get Special price or Regular Price in magento

To get Special Price or Regular Price of a product you need to Know the product Id.
Then write the code Below to fetch the All Price of a procduct

<?php 
$product= Mage::getModel('catalog/product')->load(product_id); 
$price = $product->getPrice();
$webprice = $product->getwebprice();
$specialprice = $product->getFinalPrice();
if($specialprice==$price)
{?>
<span class="price">$<?php echo number_format($price,2);?></span>
<?php } else { ?>
<div class="regular-price">
<span>Regular Price:</span>
<span class="price">$ <?php echo number_format($price,2); ?></span>
</div> 
<div class="special-price">
<span>Web Special:</span>
<span class="price">$ <?php echo number_format($specialprice,2); ?> </span>
</div>
<?php } ?>

How to get Special price or Regular Price in magento

To get Special Price or Regular Price of a product you need to Know the product Id.
Then write the code Below to fetch the All Price of a procduct

<?php
$product= Mage::getModel('catalog/product')->load(product_id);
$price = $product->getPrice();
$webprice = $product->getwebprice();
$specialprice = $product->getFinalPrice();
if($specialprice==$price)
{?>
<span class="price">Price $<?php echo number_format($price,2);?></span>
<?php } else { ?>
<div class="regular-price">
<span>Regular Price:</span>
<span class="price">$ <?php echo number_format($price,2); ?></span>
</div>
<div class="special-price">
<span>Web Special:</span>
<span class="price">$ <?php echo number_format($specialprice,2); ?> </span>
</div>
<?php } ?>

10/24/2010

Magento Set Session value and Get Session value

Set a Session value into a session Id in magento is little bit different. If you want to follow the Magento process than you must have to write the code given below to set a value and get a value of a particular Session Id.

To set Session write <?php Mage::getSingleton('core/session')->setData('session_Id'); ?>

To get that session value write

<?php Mage::getSingleton('core/session')->getData('session_Id'); ?>

10/20/2010

get value send in post method in magento

To get value send in post method , Magento use getRequest()->getParam() Method.The Proper code written below.

<?php $var = $this->getRequest()->getParam('<b>yourfieldname</b>');?>

10/06/2010

Calling a static block into phtml file in Magento

To call a static block in Magento ,You can use the following code;
<?php
echo $this->getLayout()->createBlock('cms/block')->setBlockId('Your_Static_Block_Name')->toHtml();
?>

To create your Static Block you can log into your admin panel than go to CMS->Static Blocks. There create your static Block with a name, then write the name in setBlockId() to call that into phtml file.

add facebook share button in magento

You can get Facebook share button from http://www.facebook.com/share/. But to add this in magento you need to get the current page url.
From the below code you can get the Current page Url in magento
<?php 
echo $currUrl= $this->getUrl('').$_SERVER['REQUEST_URI'];
?>
Now Write this code into the header/footer section of your site To see the Share Button
<a name="fb_share" type="button" href="http://www.facebook.com/sharer.php?u=<?php echo $currUrl;?>">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

How to get Current page url in magento

get Current page url in magento is so easy.You can get lots of solution in differnet site.But this one is the sort and best solution for getting Current page url. <?php
echo $currUrl= $this->getUrl('').$_SERVER['REQUEST_URI'];
?>

You can also use the folllowing magento features to get current page Url.

echo $this->helper('core/url')->getCurrentUrl();