Tag Archives: Magento

Override index controller magento

Here you can see how to override app/code/core/Mage/Contacts/controllers/IndexController.php .

1) Change the directory to the root of magento installation

2) vi app/etc/modules/PHPCodez_Contacts.xml

Paste the below given content

<config>
<modules>
<PHPCodez_Contacts>
<active>true</active>
<codePool>local</codePool>
</PHPCodez_Contacts>
</modules>
</config>
3) cd app/code/

4) mkdir local

5) cd local

6) mkdir PHPCodez

7) cd PHPCodez

8) mkdir Contacts

9) cd Contacts

10) mkdir controllers

11) mkdir etc

12) vi etc/config.xml

paste the below given code

<?xml version=”1.0″?>
<config>
<modules>
<PHPCodez_Contacts>
<version>0.1.0</version>
</PHPCodez_Contacts>
</modules>

<frontend>
<routers>
<PHPCodez_Contacts>
<use>standard</use>
<args>
<module>PHPCodez_Contacts</module>
<frontName>contacts</frontName>
</args>
</PHPCodez_Contacts>
</routers>
</frontend>
</conf

12)vi controllers/IndexController.php

Paste the below given code

<?php
require_once ‘Mage/Contacts/controllers/IndexController.php’;
class PHPCodez_Contacts_IndexController extends Mage_Contacts_IndexController
{
// Overrride the post function
public function postAction() {
error_log(“Overriden n”, 3, “/var/log/error-log.txt”);
// add your code to implement a tasks
}
}
?>

getFormAction() return null value contact form magento

It may happen if we try to load contact form through a static block or cms .

When you  do so make sure that you have included ‘  form_action=”/contacts/index/post ‘ .ie The code will

be

{{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}

But when we submit the contact form , the page will be redirected to the original contact form

“magento/contacts/ ” after sending the mail . To fix that we should  override the function “postAction” in

/var/www/html/app/code/core/Mage/Contacts/controllers/IndexController.php and edit the code

“$this->_redirect(‘*/*/’);” at line number 113 with the page url . ie for eg :

“$this->_redirect(‘contatcs’)

Magento Compilation

It allows us to compile all files of magento installation in order to create a single include path to improve the performance

Before compiling the code make sure that “includes” and the file “includes/config.php” must both be writeable.

You can compile the code from the admin panel  System → Tools → Compilation

NoTE: Before you make any changes to your Magento installation you should always disable compilation. Once the changes are made, run the compilation process, and then enable it.

Speed up magento

1) Install Fooman Speedste

http://www.magentocommerce.com/extension/457/fooman-speedster

2) Enable Gzip Compression in .htaccess

Add “php_flag zlib.output_compression on” in .htaccess file

3) Install APC or Xcache or memcached

4) Make sure your Apache configuration has KeepAlives enabled

5) Modify the configuration for your MySQL server to take better advantage of your server’s RAM.

6) Use a memory-based filesystem for Magento’s var directory

7) Clustering

8 ) Optimizing MySQL Database

9) Magento Caching.

10) Remove Home Page Elements

11) Compressing CSS Files

12) Changes to MySQL Configuration

13) Change from Apache to Litespeed Web Servers

KeepAlives

KeepAlives are a trick where multiple HTTP requests can be funneled through a single TCP connection. Since the setup of each TCP connection incurs additional time, this can significantly reduce the time it takes to download all the files (HTML, JavaScript, images) for a website.”