Pages

Temporarily override viewing index.php with index.html

Apache configuration file, there is a command called DirectoryIndex

DirectoryIndex index.php index.html

Change yours to look like this:

DirectoryIndex index.html index.php

Magento - billing countries different from shipping countries

app\design\frontend\default\(my_skin_name)\template\checkout\onepage\shipping.phtml

Line 103, remove or comment out this line:

<php echo $this->getCountryHtmlSelect('shipping') ?>

and replace with:

<select name="shipping[country_id]" id="shipping:country_id" class="validate-select" title="Country" onchange="shipping.setSameAsBilling(false);">

<option value=""> </option>

<option value="US" selected="selected">United States</option>

</select>

Or your own set of countries you want to show. You have the valid 2 letter country abbreviation, Magento should take care of the rest on state/province selection automatically for you.

Magento - Paypal does not allow your country of residence to ship to the country you wish to

app/code/core/Mage/Paypal/Model/Api/Standard.php
Line 237

Set the address override to "0"

If you set it to 1, the address overrides the Paypal address (the billing address), so when when it compares the addresses, if they don't match exactly, you get this error.

Magento database configuration file changed

MySQL database connection details such as hostname, database name, username etc of a Magento, you find that information into the file:

/app/etc/local.xml

Find the below lines in the file

<connection>
<host><![CDATA[hostname]]></host>
<username><![CDATA[Database Username]]></username>
<password><![CDATA[Database Password]]></password>
<dbname><![CDATA[Database Name]]></dbname>
<active>1</active>
</connection>

Virtuemart - Change Ascending / descending sort default on Browse page

Make a change to the file located in,

administrator/components/com_virtuemart/html/shop_browse_queries.php

Line #23

$DescOrderBy = $vmInputFilter->safeSQL( $vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}DescOrderBy", 'DescOrderBy', "ASC" ) );

Change to:

$DescOrderBy = $vmInputFilter->safeSQL( $vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}DescOrderBy", 'DescOrderBy', "DESC" ) );

Magento Performance Tips

Magento is a very flexible e-commerce platform.If you have a hosting configuration that should be loading your Magento pages quickly, there might be a problem in the configuration. There are a few configurations that can be easily missed, but make a large impact on performance.

Enable Flat Catalogs


Magento Community Editions 1.4 and newer, as well as Magento Enterprise Edition 1.9 and newer, offer "Flat Catalogs" that summarize the highly normalized data in flat summary tables. Using these flat summary tables makes a noticeable difference in the database query execution time.

Check your Flat Catalog configuration now to ensure that your Magento store is taking advantage of this key performance enhancement.

1. Log into your Magento administration panel
2. Navigate to System > Configuration > Catalog
3. Expand the "Frontend" accordion tab
4. Set "Use Flat Catalog Category" to "Yes"
5. Set "Use Flat Catalog Product" to "Yes"


Enable Magento Flat Catalog
Now that we have enabled the Flat Catalog options, we must refresh the indexes and populate the summary tables with the newest data.

Refresh Indexes


1. Log into your Magento administration panel
2. Navigate to System > Index Management
3. Click "Select All"
4. Set Actions to "Reindex Data"
5. Click "Submit"

The resulting screen should show all index statuses as "READY" with a green background.


Refreshed Magento Indexes

Enable JavaScript and CSS Merging


Magento offers built-in JavaScript and CSS merging. Merging JavaScript and CSS reduces page load time by combining multiple files into a single include file with the whitespace characters stripped out. This improves page load time on your customers’ web browsers.

To enable JavaScript and CSS Merging, follow these steps:

1. Log into your Magento administration panel
2. Navigate to System > Configuration
3. Click "Developer" in the left navigation
4. Expand "CSS Settings" accordion
5. In the "CSS Settings" accordion, set "Merge CSS Files" to "Yes"
6. Expand "JavaScript Settings" accordion
7. In the "JavaScript Settings" accordion, set "Merge JavaScript Files" to "Yes"


Magento Merge CSS and JavaScript Files

Use the Database To Store Sesssions


For Magento hosting configurations that have a dedicated database server, or for hosting environments with the proper hardware resources, use the database or memcached to store user sessions. Contact your hosting provider to verify that this is an option for your Magento online store.

1. Edit app/etc/local.xml
2. Inside the "session_save" element, change "files" to "db" or "memcache"

Magento get product price

Assuming that you have known product object, $_product

1. Get product price snippet

<?php echo $this->getPriceHtml($_product, true);?>

2. Get $_product price

echo $_product->getPrice();
echo number_format($_product->getPrice(), '2', '.', ',');

3. Get $_product special price

echo $_product->getSpecialPrice();
echo number_format($_product->getSpecialPrice(), '2', '.', ',');

4. Get $_product final price

echo $_prodcut->getFinalPrice();
echo number_format($_product->getFinalPrice(), '2', '.', ',');

5.Get $_product Msrp

echo $_product->getMsrp();
echo number_format($_product->getMsrp(), '2', '.', ',');

Connect to the database in Magento

$w = Mage::getSingleton('core/resource')->getConnection('core_write');

$result = $w->query('select entity_id from catalog_product_entity');

if (!$result) { return false; }

$row = $result->fetch(PDO::FETCH_ASSOC);

if (!$row) { return false; }

All model you can use below code

$products = Mage::getModel('catalog/product')->getCollection();

$products->addAttributeToFilter('entity_id', array("in"=> array(1,2) ) );

$products->addAttributeToSelect('*');

$products->load();

foreach($products as $_prod) { var_dump($_prod->getData()); }

Change Domain in Magento

If you need to update the domain name of your Magento installation, just follow these steps:

  1. Login to cPanel.
  2. Click the phpMyAdmin icon.
  3. Select your Magento database
  4. Click the link for the core_config_data table.
  5. Look for the "path" fields named web/unsecure/base_url and web/secure/base_url. (Currently, the "config_id" is 2 and 3.)
  6. Change each "value" to your new domain.
  7. You may need to empty your /var/cache/ folder before it works.

Edit Email Templates in Magento

Default place/locale. You should not customize them in the filesystem.

app/locale/en_US/template/email/

Customize email and to create a new email template you have to go to 

admin -> system -> transactional emails -> add new template -> choose the base template from the drop down and edit as appropriate.

It is possible that your email templates are already saved into the database. Then you can assign the newly created template to proper functionality.

For e.g. if you have created new template for Invoice you can assign as follows.Go to

admin -> system -> configuration -> Sales Emails -> Invoice -> Invoice Email Template

And from the drop down select the template you created for invoice and save config.

Most important step.
- Clear the Cache.
- Go to System –> Cache Management
- Refreh Cache.
- If you have not enabled the Cache OR if it didn’t work even after refreshing the cache, then
- delete the cache folder present inside var (var/cache)

How to change Joomla Admin Folder Name or Path

how to protect your admin side of website. Rename Joomla administrator directory without having to modify any Joomla code.

1. Create a new directory in your root directory (eg. "newadmin")
2. Create an index.php file in your "newadmin" directory

## newadmin/index.php

$admin_cookie_code="1234567890";
setcookie("JoomlaAdminSession",$admin_cookie_code,0,"/");
header("Location: ../administrator/index.php");

3. Add this to the beginning of index.php in real administrator folder

if ($_COOKIE['JoomlaAdminSession'] != "1234567890")
{
header("Location: ../index.php");
}


To login Joomla administration page, go to "http://yoursite.com/newadmin/". The php code will set a cookie that expires at the end of the session and redirect you to your real administration page. No one will be able to load anything from the administrator directory without having gone through the "newadmin" directory first.

Load Flash Video Before Load Front Page Joomla

Create a .htaccess file which contains the following code:

DirectoryIndex index.html index.php

Then create a index.html where you include the flash. If you make the flash linkable and have it go to the index.php it should work.