1) Change the directory to magento installation
2 cd app/code/core/Mage/Checkout/controllers
3) vi CartController.php
4) Search for $message = $this->__(‘%s was pramod added to your shopping cart.’, Mage::helper(‘core’)->escapeHtml($product->getName())); and edit the text
Monthly Archives: August 2012
Edit shipping method text on the sidebar on the checkout page Magento
1) Change the directory to magento installation
2) cd app/code/core/Mage/Sales/Model/Quote/Address/Total
3) vi Shipping.php
Edit the code at the line number 168
Edit getShippingDescription() Magento
1) Change the directory to magento installation
2) cd app/code/core/Mage/Sales/Model/Quote/Address/Total
3) vi Shipping.php
Edit the code at the line number 168
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
}
}
?>
Replace a string with another in vi editor
:%s/str1/$str2/g will replace all the occurance of str1 with str2
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’)
Success or failure messages are not being displayed contact page magento
Try by replacing
<?php getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
with
<?php
getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton(‘customer/session’)->getMessages(true)); ?>
getLayout()->getMessagesBlock()->getGroupedHtml();
?>
Edit Thank you message for Contact page in Magento
1) Change the directory to magento installation
2 cd appcodecoreMageContactscontrollers
3) vi IndexController.php
4) Search for Mage::getSingleton(‘customer/session’)->addSuccess(Mage::helper(‘contacts’)->__(‘Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.’)) and edit the text
Go to a particular line VI Editor
Type the following
:45
Modify XML node element value php
XML File – test.xml
===============
<?xml version=”1.0″ encoding=”UTF-8″?>
<PHPCodez>
<Update>
<Time>26</Time>
</Update>
</PHPCodez>
PHPCode
========
<?php
$xmlFIle = “test.xml”;
$xmlString = file_get_contents($xmlFIle);
$content=simplexml_load_string($xmlString);
echo $content->Update->Time;
$content->Update->Time = date(“Y-M-d h:i:s”);
$content->asXML($xmlFIle);
?>