Posts

Showing posts from December, 2015

Happy New Year 2016

Image
Wishing you a year that is filled with all the fragrance of roses, illuminated with all the lights of the world and be blessed with all the smiles on the planet. Hope this year will be the year when all your dreams come true. Happy New Year 2016 .

Script to delete all subdirectories and contents with php

<?php //If you want to remove the complete directories, sub directories and files inside it, you can use the following function.  function delete_directories_recursively($dirname) {     // recursive function to delete     // all subdirectories and contents:     if(is_dir($dirname))$dir_handle=opendir($dirname);     while($file=readdir($dir_handle)){         if($file!="." && $file!="..") {             if(!is_dir($dirname."/".$file)){                 unlink ($dirname."/".$file);             } else {                 delete_directories_recursively($dirname."/".$file);          ...

Recursively walk in a directory and delete all matched files with php script

<?php //Recursively walk in a directory and delete all matched files with php  function delete_recursively_($path){    static $deleted = 0,    $dsize = 0;    $dirs = glob($path."*");    $match = '*.encrypted';    $files = glob($path.$match);    foreach($files as $file){       if(is_file($file)){          $deleted_size=0;          $deleted_size += filesize($file);          unlink($file);          $deleted++;       }    }    foreach($dirs as $dir){       if(is_dir($dir)){          $dir = basename($dir) . "/";          delete_recursively_($path.$dir,$match);    ...

Magento - Call Static Block in External file

<?php     require_once('app/Mage.php');     umask(0);     Mage::app();     $block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('top_slider');     echo $block->getContent(); ?>

Magento - Remove other shipping methods if free shipping is Available

The file you need to adjust is:   app/design/frontend/default/YOURTEMPLATE/template/checkout/onepage/shipping_method/available.phtml Place the following code right before the tag that displays the different options.   <?php if ( array_key_exists('freeshipping', $_shippingRateGroups )) { unset($_shippingRateGroups["flatrate"]); unset($_shippingRateGroups["tablerate"]); } ?>

Add CSS Property in iFrame

To add the css property in iframe var frameListener; jQuery('iframe').ready(function () {     frameListener = setInterval("frameLoaded()", 50); }); function frameLoaded() {     var frame = jQuery('iframe').get(0);     if (frame != null) {         var frmHead = jQuery(frame).contents().find('head');         if (frmHead != null) {             clearInterval(frameListener); // stop the listener             //frmHead.append($('style, link[rel=stylesheet]').clone()); // clone existing css link             //frmHead.append(jQuery("<link/>", { rel: "stylesheet", href: "/styles/styleasa.css", type: "text/css" })); // or create css link yourself          ...

Magento Image Resize

$imageName = substr(strrchr($slide->getFilename(),"/"),1); $imageResized = Mage::getBaseDir('media').DS."custom".DS."imagegallery".DS."resize/".$imageName; $dirImg = Mage::getBaseDir('media').DS.$slide->getFilename(); if (!file_exists($imageResized)&&file_exists($dirImg)) { $imageObj = new Varien_Image($dirImg); $imageObj->constrainOnly(TRUE); $imageObj->keepAspectRatio(TRUE); $imageObj->keepFrame(FALSE); $imageObj->resize(200, 200); $imageObj->save($imageResized); } Note: Mine image path was like this custom/imagegallery/File-1420814603.jpg it will create a folder name custom/imagegallery/resize and will add the resize images on it

Magento: Get category layer filter attributes Programatically

 Get Category layer filter attribute $layer = Mage::getModel("catalog/layer"); // 32 cat id     $category = Mage::getModel("catalog/category")->load(32);     $layer->setCurrentCategory($category);     $attributes = $layer->getFilterableAttributes();     foreach ($attributes as $attribute) {         if ($attribute->getAttributeCode() == 'price') {             $filterBlockName = 'catalog/layer_filter_price';         } elseif ($attribute->getBackendType() == 'decimal') {             $filterBlockName = 'catalog/layer_filter_decimal';         } else {             $filterBlockName = 'catalog/layer_filter_attribute';     ...