Search This Blog

Friday 22 November 2013

Install SSL on Apache

Tuesday 12 November 2013

How to create Layered Navigation for custom product collection?

Product image zoom free extensions

One Step checkout free extensions

One Step checkout free extensions:

http://www.magentocommerce.com/magento-connect/onecheckout-checkout-in-one-step-on-one-page-2559.html

http://www.magentocommerce.com/magento-connect/express-checkout-one-step-checkout-free-8118.html

http://www.magentocommerce.com/magento-connect/iwd-free-one-page-one-step-checkout.html

http://www.magentocommerce.com/magento-connect/0-step-checkout-9378.html

http://www.magentocommerce.com/magento-connect/swiftcheckout-free-single-page-checkout.html

http://www.magentocommerce.com/magento-connect/skip-checkout-step-1.html


Add discount coupon code in checkout review step:
http://www.magentocommerce.com/magento-connect/add-discount-coupon-with-checkout-process.html

 Quick contact form extension:
http://www.magentocommerce.com/magento-connect/freequickcontact-mageworld.html

Monday 14 October 2013

Disable the Plugin and Theme Editor | Disable Plugin and Theme Update and Installation

Perl script for documents backup

#!/usr/bin/perl

# Configuration params
$backup_dir = '/home/username/public_html';
$file_prefix = 'doc_backup_';

# Get the timestamp for today
$date = `date "+%Y%m%d"`;
chomp($date);

chdir('/home/username/backup/doc_backup') ;

`tar -cv -f $file_prefix$date.tar $backup_dir`;

`bzip2 $file_prefix$date.tar`;

# Below line is used to remove the backups older than 5 days to free up the server space
system("find . -mtime +5 -type f -name  'doc_backup_*' -exec rm {} \\;");

Perl script for Database backup


#Configuration params
$host = 'localhost';
$user = 'username';
$pass = 'password';
$database = 'dbname';
$backup_dir = '/home/username/backup/db_backup';
$file_prefix = 'database_backup_';

# Get the timestamp for today
$date = `date "+%Y%m%d"`;
chomp($date);

`mysqldump --host=$host --user=$user --pass=$pass  $database | bzip2 -c > $backup_dir/$file_prefix$database$date.sql.bz2`;


Wednesday 25 September 2013

Using Dynamic Class names

Increase number of emails to be sent via Nesletter

To increase the number emails to be sent for every 5 min:

In app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php

Change the 

$countOfSubscritions = 20;

To

$countOfSubscritions = 100; // whatever number you want

Also in app/code/core/Mage/Newsletter/Model/Oberver.php

Change the

$countOfSubscritions = 20;

To

$countOfSubscritions = 100; // whatever number you want

Extend the core admin controller

Sunday 22 September 2013

Get Default Magento store ID

$defaultStoreId = Mage::app()
    ->getWebsite(true)
    ->getDefaultGroup()
    ->getDefaultStoreId();

Tuesday 17 September 2013

Magento Newsletter UnSubscribe Link

Script to get Unsubscribe link:

Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getUnsubscriptionLink();

Code snippet to be used in email templates:
<a href="{{var subscriber.getUnsubscriptionLink()}}">{{var subscriber.getUnsubscriptionLink()}}</a>

Tuesday 27 August 2013

How to allow certain tags (iframe, embed) in Magento's CMS editor?

CyberSource Payment Gateway Field validations and Guides



Field Validation


Notification

As part of its commitment to maintain industry-leading security and data integrity, CyberSource will be implementing additional front-end validation of transaction data entering it's Systems, starting on January 22nd, 2013.

As part of this effort, CyberSource will start performing additional validation on certain API field values coming into the Production environment across all connection methods, including several fields in the following groups:

                Customer Information and Address Fields

                Order Tracking Fields

After extensive testing versus past production transaction data, we are confident that these changes will be transparent to the vast majority of our customer base.  However, if you do see any perceived changes in data validation-related declines, please feel free to contact CyberSource Customer Support for further assistance in troubleshooting said transactions. 

Cyber Source Simple Order SDK Tool Kit:

Documentation on fields:

Development Guides:


Tuesday 20 August 2013

SSH using .pem

Search the date range between two dates SQL



CREATE TABLE `product_sales` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  `From_date` date NOT NULL,
  `To_date` date NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `Product_sales`
--

INSERT INTO `Product_sales` (`id`, `name`, `From_date`, `To_date`) VALUES
(1, 'Product 1', '2013-08-20', '2013-08-30'),
(2, 'Product 2', '2013-08-14', '2013-08-27'),
(3, 'Product 3', '2013-08-25', '2013-08-31'),
(4, 'Product 4', '2013-08-10', '2013-08-22'),
(5, 'Product 4', '2013-08-24', '2013-08-28'),
(6, 'Product 4', '2013-08-23', '2013-08-30');

QUERY:
SELECT * FROM Product_sales WHERE ( From_date >= '2013-08-19' AND To_date <= '2013-08-23' ) OR ( To_date >= '2013-08-19' AND From_date <= '2013-08-23' )

Thursday 18 July 2013

Add custom field / attribute to Google Calendar Event using API

An extended property is an arbitrary name/value pair that can be added to an event and retrieved via the API. It is not accessible from the calendar web interface.

https://developers.google.com/gdata/docs/2.0/elements?hl=fr#gdExtendedProperty

Friday 5 July 2013

Adding new / update / delete category attribute in Magento


<?php
/** @var $this Mage_Eav_Model_Entity_Setup */
$this->startSetup();

/** Remove existing atribute */
$this->removeAttribute('catalog_category', 'size_chart');

/** Add new atribute */
$this->addAttribute('catalog_category', 'short_description', array(
    'group'         => 'General Information',
    'input'         => 'textarea',
    'type'          => 'text',
    'label'         => 'Short Description',
    //'source'        => 'categoryattributes/source_sizechart',
    'backend'       => '',
    'visible'       => 1,
    'required'      => 0,
    'user_defined'     => 1,
    'note'             => 'Category Short Description will be shown in bottom  3 boxes of other category pages',
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
/** Update existing atribute */
$categoryEntityTypeId = $this->getEntityTypeId('catalog_category');
$this->updateAttribute($categoryEntityTypeId, 'short_description', 'is_wysiwyg_enabled', 0);
$this->updateAttribute($categoryEntityTypeId, 'short_description', 'is_html_allowed_on_front', 0);

$this->endSetup();

?>
http://www.atwix.com/magento/add-category-attribute/

Tuesday 25 June 2013

Magento Dataflow - Optimized Product Import

Pointers to get started with Magento


Below are the pointers to get started with Magento
  1. System Requirements 
    1. http://www.magentocommerce.com/system-requirements 
  2. Folder Structure 
    1. http://www.magentocommerce.com/wiki/2_-_magento_concepts_and_architecture/magento-folder-structure 
  3. Technical Documentation 
    1. http://docs.magentocommerce.com/ 
  4. Knowledge Base 
    1. http://www.magentocommerce.com/knowledge-base 
    2. This will have following: 
      1. Knowledge Base Home 
      2. Installation & Configuration 
      3. Build Your Store Manage Your Store 
      4. Expand Your Store 
      5. Themes and Design Development 
      6. Magento Connect 
  5. User Guides 
    1. http://www.magentocommerce.com/resources/magento-user-guide 
  6. Magento API 
    1. http://www.magentocommerce.com/api/soap/introduction.html

Friday 3 May 2013

Download files from server using command line and PSCP in Windows

1)        Download pscp.exe
2)        Run >> CMD >> cd program files[location of pscp.exe]
3)        pscp -r username@HOSTIPADDRESS:/var/www/vhosts/abc.com/httpdocs/ C:\backupfiles\httpdocs\
4)        http://www.linuxquestions.org/questions/linux-newbie-8/scp-copy-file-from-remote-linux-server-onto-a-windows-machine-316263/

Wednesday 17 April 2013

Log Clearing Script Magento



<?php
$xml = simplexml_load_file('./app/etc/local.xml', NULL, LIBXML_NOCDATA);

$db['host'] = $xml->global->resources->default_setup->connection->host;
$db['name'] = $xml->global->resources->default_setup->connection->dbname;
$db['user'] = $xml->global->resources->default_setup->connection->username;
$db['pass'] = $xml->global->resources->default_setup->connection->password;
$db['pref'] = $xml->global->resources->db->table_prefix;

if($_GET['clean'] == 'log') clean_log_tables();
if($_GET['clean'] == 'var') clean_var_directory();

function clean_log_tables() {
 global $db;
 
 $tables = array(
  'dataflow_batch_export',
  'dataflow_batch_import',
  'log_customer',
  'log_quote',
  'log_summary',
  'log_summary_type',
  'log_url',
  'log_url_info',
  'log_visitor',
  'log_visitor_info',
  'log_visitor_online',
  'index_event',
  'report_event',
  'report_compared_product_index',
  'report_viewed_product_index',
  'catalog_compare_item',
  'catalogindex_aggregation',
  'catalogindex_aggregation_tag',
  'catalogindex_aggregation_to_tag'
 );
 
 mysql_connect($db['host'], $db['user'], $db['pass']) or die(mysql_error());
 mysql_select_db($db['name']) or die(mysql_error());
 
 foreach($tables as $v => $k) {
  @mysql_query('TRUNCATE `'.$db['pref'].$k.'`');
 }
}

function clean_var_directory() {
 $dirs = array(
  'downloader/.cache/*',
  'downloader/pearlib/cache/*',
  'downloader/pearlib/download/*',
  'var/cache/',
  'var/locks/',
  'var/log/',
  'var/report/',
  'var/session/',
  'var/tmp/'
 );
 
 foreach($dirs as $v => $k) {
  exec('rm -rf '.$k);
 }
}

Sunday 14 April 2013

Magento Module Creator

Magento send emails using SMTP

In order to allow magento to use SMTP instead of the usual mail function, you need to take the below steps.
- Login to magento admin and go to. System->Configuration->Advanced->System->Mail Sending Settings
- Now here set the host value to your smtp host name like
mail.domain.com

- And then the default port is 25.
- Now you need to change magento file. Do not edit the core file as you will loose your change in an upgrade.
- So copy this file app/code/core/Mage/core/Model/Email/Template.php in to your local, by creating the same folder structure.
- Enable that module.
- Then in Template.php you will have to change the getMail() function as below.

public function getMail()
    {
        if (is_null($this->_mail)) {
            /* changes begin */
           $my_smtp_host = Mage::getStoreConfig('system/smtp/host');
           $my_smtp_port = Mage::getStoreConfig('system/smtp/port');
           $config = array(
                    'port' => $my_smtp_port,
                    'auth' => 'login',
                    'username' => 'email@domain.com',
                    'password' => 'yourpassword'
                );
            $transport = new Zend_Mail_Transport_Smtp($my_smtp_host, $config);
            Zend_Mail::setDefaultTransport($transport);
            /* Changes End */
            $this->_mail = new Zend_Mail('utf-8');
        }
        return $this->_mail;
    }

- After this clear your cache.
- Now magento will be able to send emails for you.
 

Magento Free extension to find the conflicts

Thursday 11 April 2013

Magento Community Edition (CE) 1.8 and Enterprise Edition (EE) 1.13 Released


 Highlights
  • Major overhaul of tax calculation formulas, correction of rounding errors, and additional assistance with configuration
  • Most indexing processes now run only to update products, categories, URL redirects, and so on that have changed—eliminating the need for manual full reindexing
  • Additional option of using Redis NoSQL for cache and session storage in multi-host deployments (recommended for new deployments)
  • Full page caching now invalidates only pages that are affected by product or category changes
  • Optimized cache adapters for single-server systems
  • Elimination of many types of database deadlocks


http://www.magentocommerce.com/knowledge-base/entry/ce-18-and-ee-113-documentation-home

Friday 5 April 2013

Disable Author pages in Wordpress


 Open your theme’s functions.php and put this in:


/* Kill attachment, search, author, daily archive pages */
add_action('template_redirect', 'bwp_template_redirect');
function bwp_template_redirect()
{
 global $wp_query, $post;

 if (is_author() || is_attachment() || is_day() || is_search())
 {
  $wp_query->set_404();
 }

 if (is_feed())
 {
  $author  = get_query_var('author_name');
  $attachment = get_query_var('attachment');
  $attachment = (empty($attachment)) ? get_query_var('attachment_id') : $attachment;
  $day  = get_query_var('day');
  $search  = get_query_var('s');

  if (!empty($author) || !empty($attachment) || !empty($day) || !empty($search))
  {
   $wp_query->set_404();
   $wp_query->is_feed = false;
  }
 }
}


The snippet above will effectively disable attachment pages, search page, author pages and daily archive pages. Automatically generated feeds for those pages will also be disabled.

You can find more conditional tags at: http://codex.wordpress.org/Conditional_Tags

Source: http://betterwp.net/wordpress-tips/disable-some-wordpress-pages/

Tuesday 19 March 2013

Database table fields type using PHP

 Script to list all the field data types in specified database and create a CSV file then download the CSV file.

<?php
set_time_limit(0);
getUniqueFieldTypes('HOSTNAME','DATABASE USERNAME','PASSWORD','DATABASENAME');

function getUniqueFieldTypes($host,$user,$pass,$name,$tables = '*')
{
   
    $link = mysql_connect($host,$user,$pass) or die('Could not connect');
    mysql_select_db($name,$link);
   
    //Get all of the tables
    if($tables == '*')
    {
        $tables = array();
        $result = mysql_query('SHOW TABLES');
        while($row = mysql_fetch_row($result))
        {
            $tables[] = $row[0];
        }
    }
    else
    {
        $tables = is_array($tables) ? $tables : explode(',',$tables);
    }
    $dataTypes = array();
    //Cycle through
    foreach($tables as $table)
    {
        $result = mysql_query('SHOW FIELDS FROM '.$table);
        $num_fields = mysql_num_fields($result);
   
        while($row = mysql_fetch_row($result))
        {
            $dataTypes[$row[1]] = $row[1];
        }
        //sleep(1);
    }
    asort($dataTypes);

    $fp = fopen('fields.csv', 'w+');
    foreach($dataTypes as $dataType) {
        $values = array($dataType);
        fputcsv($fp, $values);
    }
   fclose($fp);
   $file = 'fields.csv';
   
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile($file);
        exit;
    }
   
}
?>
<html>
    <head>
        <title>Create CSV with list of field data types</title>
    </head>
</html>

Below are the list data types supported by MYSQL:
VARCHAR
TINYINT
TEXT
DATE
SMALLINT
MEDIUMINT
INT
BIGINT
FLOAT
DOUBLE
DECIMAL
DATETIME
TIMESTAMP
TIME
YEAR
CHAR
TINYBLOB
TINYTEXT
BLOB
MEDIUMBLOB
MEDIUMTEXT
LONGBLOB
LONGTEXT
ENUM
SET
BOOL
BINARY
VARBINARY