How to get parent category Id in Magento

To get Parent Category Id you must know the current category Id, for that you need to write

$_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();?>

Now you can get Parent Category Id.

write the code given below to get the Id

 <?php $parentId=Mage::getModel('catalog/category')->load($curent_cat_id)-&gt;getParentId();
echo  $parentId; // $parentId will print your current category's parent Id

Magento connect manager Internal server error

This is the most common problem for all Magento User.This problem is only for the File Permission in the server.To solve this Problem first you need to login to your FTP(File Transfer Protocol), then go to your magento installation path their you will find downloader Change the file permission to 755 , Again goto the index.php file inside downloader folder and change the file permission to 755.Now refresh the page you will see the effect.

How to Get Current Category Id or Name in Magento

get Current category in magento is so much easy

If you wish to check the current category in everypage(including Homepage as default category is 2) then you can write these code

$_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();
$category = Mage::registry('current_category')->getName();

By the Help of registry()function of magento we can get the Current category ,For get name of that category we can use getName() function .If you need the Id then write getId() instead of getName();

Set Session ID and Get Session Id in Magento

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','value'); ?>

To get that session value write

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

Calling a static block into a phtml file in Magento

Calling a static block into a phtml file in Magento

To call a static block in Magento ,You can use the following code;

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.

How to Change My Cart text in magento

To Change the text of My Cart in top links you need to go app/code/core/Mage/Checkout/Block/ there you will find Links.php .there will be below function

public function addCartLink()
if ($parentBlock = $this->getParentBlock()) {
$count = $this->helper(’checkout/cart’)->getSummaryCount();
if( $count == 1 ) {
$text = $this->__(’My Cart (%s item)’, $count);
} elseif( $count > 0 ) {
$text = $this->__(’My Cart (%s items)’, $count);
} else {
$text = $this->__(’My Cart’);
$parentBlock->addLink($text, ‘checkout/cart’, $text, true, array(), 50, null, ‘class="top-link-cart"’);
return $this;

Change “My Cart” to your required text and Upload it to server.then clear the catche to see the effect

How to show Related products on product details page in Magento

Open catalog.xml And Paste it under Product view Section under <reference name=”content”>

<block type=”catalog/product_list_related” name=”catalog.product.related” before=”-” template=”catalog/product/list/related.phtml”/>

Then go to view.phtml which resides under the catalog/product in your Magneto template and write

getChildHtml(‘related’); ?>

In the required place of your page.

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 (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.

Now refresh your cache to see the effect.

How to Change default Home page url to any page or login url in Magento

To change default index page of magento any cms page or any page like login page is quite easy .To do so you need to login to the admin panel then goto System -> Configuration , then click on web tab from the right side tab.Now click on Default Pages tab and change the Default web url as per your required Url.Here is one example where I have changed my Homepage url to Login page Url

Change default Home page url to any page url in Magento