Skip to main content

Posts

Identify Home page in Magento

<?php $routeName = Mage::app()->getRequest()->getRouteName(); $identifier = Mage::getSingleton('cms/page')->getIdentifier(); if($routeName == 'cms' && $identifier == 'home') { echo 'You are in Homepage!'; } else { echo 'You are NOT in Homepage!'; } ?>

Insert Data from excel into database

<?php //your database connection here... //$_POST["Import"]   this is data which you want to insert $sql=''; if(isset($_POST["Import"])) { $filename=$_FILES["file_product"]["tmp_name"]; $type=$_FILES["file_product"]["type"]; //print_r($_FILES);  if($_FILES["file_product"]["size"] > 0) {   $file = fopen($filename, "r"); while (($emapData = fgetcsv($file, 50000, ",")) !== FALSE) {  if($emapData[0]!="")  {   $t=mysql_escape_string(trim($emapData[2]));   $t1=strlen($t);   $city=mysql_escape_string(trim($emapData[7]));   $city1=strlen($city);   $state=mysql_escape_string(trim($emapData[8]));   $state1=strlen($state);   $zip=mysql_escape_string(trim($emapData[9]));   $zip1=strlen($zip);   $sql=rtrim($sql,','); $sql ="insert into yourtable (phone_no, firstname, lastnam

Add Rating Star in product in magento

Step :1   Go to app/design/frontend/base/default/template/catalog/product/view.phtml   In the  view .phtml  file find the following code  <?php //echo $this->getReviewsSummaryHtml($_product, false, true)?> Replace with this code:  <?php echo $this->getReviewsSummaryHtml( $_product, 'short' )?>

ADD “HOME” LINK IN MAGENTO TOP NAVIGATION MENU

design/frontend/default/yourtheme/template/page/html/topmenu.phtml /*design/frontend/default/yourtheme/template/catalog/navigation/top.phtml*/ replace following code to:- <?php $_menu = $this ->getHtml( 'level-top' ) ?> <?php if ( $_menu ): ?> <div class = "nav-container" >      <ul id= "nav" >           <!-- HOME BUTTON HACK -->          <?php $_anyActive = false; foreach ( $this ->getStoreCategories() as $_category ) { $_anyActive = $_anyActive || $this ->isCategoryActive( $_category ); } ?>          <li class = "<?php echo !$_anyActive ? 'active' : '' ?>" ><a href= "<?php echo $this->getUrl('')?>" ><?php echo $this ->__( 'Home' ) ?></a></li>          <!-- HOME BUTTON HACK -->          <?php echo $_menu ?>      </ul> </div> <?php endif ?>

Show category Image in main Navigation in magento

In Model file. (/app/code/core/Mage/Catalog/Model/Observer.php) Update following code in Function Name: _addCategoriesToMenu $categoryData = array ( 'name' => $category -> getName (), 'id' => $nodeId , 'url' => Mage :: helper ( 'catalog/category' )-> getCategoryUrl ( $category ), 'is_active' => $this -> _isActiveMenuCategory ( $category ), 'thumbnail' => Mage :: getModel ( 'catalog/category' )-> load ( $category -> getId ())-> getThumbnail () ); Then go into Html folder. (app/code/core/Mage/Page/Block/Html/Topmenu.php) Update the following line of code at line 131 in Function name: _getHtml replace : $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';             $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '>