How to place the content for only Homepage in Magento
Aug01

How to place the content for only Homepage in Magento

How to place the content for only Homepage in Magento? Following code is useful to place the content in only homepage not in other pages. <?php if ($this->getIsHomePage()):?> Homepage content goes here... <?php else:?> Other pages content except Homepage goes here... <?php endif?>

Read More
Remove the index.php from Magento Admin URL
Jul27

Remove the index.php from Magento Admin URL

To remove the index.php from Magento admin URL add the following code on the top of the /shop/index.php file in Magento folder: <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $curUrl = curPageURL(); $pos = strpos($curUrl, "index.php"); // Note our use of ===. Simply == would not work as expected // because the position of 'a' was the 0th (first) character. if ($pos === false) { //echo "The string '$findme' was not found in the string '$mystring'"; } else { //echo "The string '$findme' was found in the string '$mystring'"; //echo " and exists at position $pos"; $newUrl = str_replace("index.php/", "", $curUrl); header("Location: $newUrl"); exit; } ?> Enjoy...

Read More
Get the parent category ID and present category ID in Magento
Jul15

Get the parent category ID and present category ID in Magento

Get the parent category ID and present category ID using below code in Magento Present Category ID: <?php $_cat = new Mage_Catalog_Block_Navigation(); $curent_cat = $_cat->getCurrentCategory(); echo $curent_cat_id = $curent_cat->getId(); ?> <br /> Parent Category ID: <?php $parentId=Mage::getModel('catalog/category')->load($curent_cat_id)->getParentId(); echo $parentId; // $parentId will print your current category’s parent Id...

Read More

Insert CMS static block into Transactional email template in magento

1. Create CMS block, make sure identifier of block matches. 2. Use the following to add CMS block in transactional email template {{block type="cms/block" block_id="your-static-block-identifier" }}

Read More

Want to Change background color on Magento product image resize

You can update this when you draw/resize the image. This is from template/catalog/product/list.phtml <?php echo $this->helper('catalog/image')->init($_product, 'small_image')->backgroundColor(228,208,177)->resize(135, 135); ?> Just add in the backgroundColor call before the resize. The color is set in separate numerical values for red, green and blue (it won’t take a hex...

Read More

In Magento Admin “No input file specified”.

I installed Magento in godaddy. When I logged into the admin section, it shows “No input file specified”. Answer: 1. Goto Your Godaddy Account. 2. Click on My Account and click on your hosting account. 3. Go to Settings > File Extensions Management 4. Change .php and .php5 to run under PHP5.2X (instead of PHP5.2xFastCGI)

Read More
'