Add code

Thursday 28 July 2016

Shopping cart is going to empty after cancelled the payment at checkout page

Please `open app/code/core/Mage/Checkout/controllers/OnepageController.php`

Search for 

$this->getOnepage()->getQuote()->save();
 
 //this makes the cart empty (sets the quote as converted to order)
    if (isset($redirectUrl)) {
        $result['redirect'] = $redirectUrl;
    } 
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
 
And replace this with the following.

if (isset($redirectUrl)) {
    $result['redirect'] = $redirectUrl;
    $this->getOnepage()->getQuote()->setIsActive(1) ;
}
$this->getOnepage()->getQuote()->save();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));

Friday 29 April 2016

How to Add the list of cities in states to Magento.


Adding the list of cities in states to Magento.
 I have tested this and worked for me on my server.
 I have used the Region & City Manager extension.
Region & City Manager extension allows you to add regions and cities for any countries in the world.

Check once the extension from here :

https://www.magentocommerce.com/magento-connect/catalog/product/view/id/30552/s/region-city-manager/

Monday 21 March 2016

Hide Magento Attributes with no Value

This can be done with a small piece of code. Find and open the attributes.phtml file. This file can be found here:/app/design/frontend/[theme name]/[package name]/template/catalog/product/view/attribute.phtml
Open the file and search for the following lines:


<?php foreach ($_additional as $_data): ?>
    <tr>
        <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
        <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
    </tr>
<?php endforeach; ?>

Replace the entire foreach loop with the following lines of code:

<?php foreach ($_additional as $_data): ?>
    <?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
    if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
    <tr>
        <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
        <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
    </tr>
    <?php } ?>
<?php endforeach; ?>

<?php foreach ($_additional as $_data): ?>
    <?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
    if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
    <tr>
        <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
        <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
    </tr>
    <?php } ?>
<?php endforeach; ?>

Friday 19 February 2016

How to move magento search bar from header to sidebar?

Edit "app/design/frontend/<your theme>/<your theme>/layout/catalogsearch.xml"

Fine the line:


<reference name="header">
    <block as="topSearch" name="top.search" template="catalogsearch/form.mini.phtml" type="core/template">
</block>
</reference>

Replace the reference name to left or right.

<reference name="left or right(your wish)">
    <block as="topSearch" name="top.search" template="catalogsearch/form.mini.phtml" type="core/template">
</block>
</reference>

Maximum execution time of 30 seconds exceeded

To fix it, open your php.ini and replace the value for 'max_execution_time' and 'max_input_time' as per below.


max_execution_time = 3600
max_input_time = 3600

How to show only first name in magento welcome message?

Comment the welcome message code in "template/page/html/header.phtml" and Use the below code to show first name only.



$customer = Mage::getSingleton('customer/session')->getCustomer()->getData();
if(Mage::getSingleton('customer/session')->isLoggedIn()){
   echo $this->__('Welcome, %s!', $customer['firstname']);
}else{
   echo $this->__('Welcome Guest');
}

How do I change SHOP BY text in left sidebar Magento?

Are you trying to replace the "SHOP BY" text? And failed to replace the text? Don't worry, that is not actually a text. That is Image.

Solution 1: You will need to replace the image under

"skin/frontend/default/default/images/bkg_block-layered-title.gif";


Solution 2: Locate a file

"app/design/frontend/default/YOURTHEME/template/catalog/layer/view.phtml" Change the class name "block-title" to something else.

Wednesday 10 February 2016

How to remove my account,my wishlist in magento account link on home page?

To remove My Account link :

Open the file /app/design/frontend/package/theme/layout/customer.xml and comment these lines
 
<!--<action method="addLink" translate="label title" module="customer">
<label>My Account</label>
<url helper="customer/getAccountUrl"/>
<title>My Account</title><prepare/><urlParams/>
<position>10</position>
</action>-->

To Remove Wishlist link :

Open the file /app/design/frontend/package/theme/layout/wishlist.xml and comment these lines.
<!--<reference name="top.links">
    <block type="wishlist/links" name="wishlist_link"/>
    <action method="addLinkBlock">
<blockName>wishlist_link</blockName>
</action>
</reference>--> 

To Remove My Cart link :

Open the file /app/design/frontend/package/theme/layout/checkout.xml and comment these lines
<!-- <action method="addCartLink"></action> -->

To Remove Checkout link :

Open same file, /app/design/frontend/package/theme/layout/checkout.xml and comment the lines
<!-- <action method="addCheckoutLink"></action>-->

Thursday 4 February 2016

How to remove the index.php in magento?

To remove index.php from URLs follow the below steps :
  1. Log-in Magento Admin.
  2. Go to System -> Configuration -> Web.
  3. From Search Engine Optimisation tab Use Web Server Rewrites select YES.
  4. Make sure your Secure and Unsecure base urls should end with “/”.
  5. And in System -> Configuration -> Web -> Secure -> Use secure URLs in the frontend, select YES.  
  6. now edit your .htaccess ( will be in magento root folder ) and pate the below code and save:   

1<IfModule mod_rewrite.c>
2RewriteEngine On
3RewriteBase /
4RewriteRule ^index\.php$ - [L]
5RewriteCond %{REQUEST_FILENAME} !-f
6RewriteCond %{REQUEST_FILENAME} !-d
7RewriteRule . /index.php [L]
8</IfModule>


now your index.php issue will be solved.
** if that still does not work, then make sure you have mod_rewrite enabled / installed on your server.

Monday 1 February 2016

New order email confirmation not being sent

Avoid cron:

 Transactional emails will be sent instantly.


goto following path: 

//app/code/core/Mage/Sales/Model/Order.php Line#1356,1450 
  //$mailer->setQueue($emailQueue)->send(); Change To 

          $mailer->send();

app/design/frontend/base/default/template/checkout/success.phtml
 //add following line Top success page for sending mail direct
 // Start Send Email Here......
$order = Mage::getModel('sales/order');
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
$order->loadByIncrementId($incrementId);

    try{ $order->sendNewOrderEmail();} 
    catch (Exception $ex) { echo "Email Not Sent..."; }
    $customer = Mage::getSingleton('customer/session')->getCustomer();
    $email = $customer->getEmail();//End Email Sending



Thursday 28 January 2016

How can we find Magento version through code?

We may find the Magento website which version is using is now easy to find out.

Just open the path from your root folder /app/Mage.php

Near 168 line, you can find the following code :

   public static function getVersionInfo()
    {
        return array(
            'major'     => '1',
            'minor'     => '8',
            'revision'  => '1',
            'patch'     => '2',
            'stability' => '',
            'number'    => '',
        );
    }

It means we are using the 1.8.1.2 version.

How to find the difference between Mage::getModel() and Mage::getSingletone() in Magento

To know about Mage::getSingletone():

It is used for Always finds for an existing object if not then create that a new object.


To know about Mage::getModel():

It is used for Always creates a new object.


Magento : 404 error is showing admin page

Hello, Sometimes we may get the error on admin page once done with the Magento installation. In that scenario, we have to do the following: ...