Payment has failed, please reload checkout page and try again. Your card has not been charged

ReferenceError: Ebizmarts SagePay Suite is not defined

I just played with the following code in /magento/app/code/local/Ebizmarts/SagePaySuite/Model/Observer/Sales.php


$dbtrn = $this->_getTransactionsModel()->loadByParent($order->getId());

#For empty payments or old orders (standalone payment methods).
if( (Mage::app()->getRequest()->getControllerModule() == ‘Mage_Api’) || Mage::registry(’current_shipment’) || Mage::registry(’sales_order’) || Mage::registry(’current_creditmemo’) || Mage::registry(’current_invoice’)){
return $o;

$logfileName = $order->getIncrementId() . ‘-’ . time() . ‘_Payment_Failed.log’;

$request_data = $_REQUEST;
if( isset($request_data[’payment’]) ){
$request_data[’payment’][’cc_number’] = ‘XXXXXXXXXXXXX’;
$request_data[’payment’][’cc_cid’] = ‘XXX’;

Sage_Log::log($order->getIncrementId(), null, $logfileName);
Sage_Log::log(Mage::helper(’core/http’)->getHttpUserAgent(false), null, $logfileName);
Sage_Log::log(print_r($request_data, true), null, $logfileName);
Sage_Log::log(’——————–’, null, $logfileName);

Mage::throwException(’Payment has failed, please reload checkout page and try again. Your card has not been charged.’);

return $o;

If I change the fist line from




Payment is successful.

Managing Magento Product Images of magento

how to resize the base images in magento
that it
The following image types are used throughout the catalog, and you can choose which image you want to use for each. If you do not assign an image to each type, image will be used instead.

Thumbnail The thumbnail image appears in the thumbnail gallery, shopping cart, and in some blocks such as Related Items.
Example Size: 50 x 50 pixels
Small Image The small image is used for the product images in listings on category and search results pages, and to display the product images needed for sections such as Up Sells, Cross Sells, and the New Products list.
Example Size: 265 x 265 pixels
Base Image The base image is the main image on the product detail page. Image zoom is activated if you upload an image that is larger image than the image container.
Example Size: 265 x 265 pixels (without zoom)
Example Size: 1100 x 1100 pixels (with zoom)

By default, the container that holds the product image is square. As a result, you can take full advantage of the available space by making your product images square. However, regardless of their size or shape, images are automatically resized to fit the width of the container, which makes it possible to upload a single image and assign it to all three types.

The base image is the place to start, because it determines the level of magnification that is available for image zoom, and can be reduced to any smaller size that is needed. In one scenario, a single image (1100 x 1100 pixels) can be uploaded and assigned to all three types. Then additional images (470 x 470 pixels) can be uploaded to show different views of the product.


You can change magento’s default product image placeholders in admin, Goto –
System->Configuration->Catalog->Product Image Placeholders

Product image watermarks also editable, change them here –
System->Configuration->Design->Product Image Watermarks

Changing the Size of Catalog Images


Sometimes you need to change product image size in product list page, product details page, related/recent/last ordered products list, … So let’s see how to change product image size on some pages:

1. How to change image size on product list page

Open file:


Change resize(what_size_you_want) in line:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

2. How to change main image size on product details page

Open file:


Change resize(what_size_you_want) in line:

$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');

3. How to change thumbnail image size on product details page

Open file:


Change resize(what_size_you_want) in line:

<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />


Ideal Size&Resolution for magento product images


To persuade your consumers to buy your products over the internet is not an easy task. The consumer is on their own, without help from your sales staff, trying to make a buying choice. Product imagery plays a crucial role in eCommerce. When a consumer buys a product, without touching and feeling it, detailed product photographs become the key to selling.

When it comes to product images, business owners find it difficult to decide on image quality, resolutions, dimensions, file size, format, etc. The following are the ideal settings that you should use while saving images for your eCommere website. JPEG is the best file format for photographic imagery. The width and height are given as indicators only. If the image is of a portrait format, the width and height settings will have to swap. The maximum file size of 200kb is good for the main product image. This will ensure fast page loading speeds. Most images at the following settings will not reach 200kb, but if they do, try and compress the quality a bit further.

File Format: JPEG
Max. Width: 1600 pixels
Max. Height: 1200 pixels
Max. File Size: 200 kb

If you have many images to be resized and wish to save time, you can download and follow the <a title="Optimise Guide to Batch Resizing Images" Optimise Guide to Batch Resizing Images.


Why Magento is decreasing my product images quality?


I discovered that Magento uses GD2, with a quality setting to 80% by default (not changeable via configuration, back-office or XML). A value 80/100 quality is good in most cases. Nevertheless in e-commerce have known that a very good picture quality can make the difference.

The idea is to push the compression quality (jpeg) to 90%, the possible options are:

  1. A new method called setQuality has been implemented after Magento CE version 1.4 and EE 1.8 and can be used directly in templates.
    For example: echo $this->helper(‘catalog/image’)->init($this->getProduct(), ‘image’, $_image->getFile())->resize(42, 50)->setQuality(90);
  2. Change the compression quality photos Magento later than version 1.4:

Step 1

Copy the file “/ lib/Varien/Image/Adapter/Gd2.php” to “/ app/code/local/Varien/Image/Adapter/Gd2.php” by creating the missing directories if necessary.

Step 2

Open the file Gd2.php (copy, not original) at about line 80 and substitute:

call_user_func($this->_getCallback('output'), $this->_imageHandler, $fileName);


if ($this->_fileType === IMAGETYPE_JPEG) {
call_user_func($this->_getCallback('output'), $this->_imageHandler, $fileName, 90);
} else {
call_user_func($this->_getCallback('output'), $this->_imageHandler, $fileName);

Step 3

Finally, don’t forget to empty the cache of images via System> Cache Management.
That was simple, effective and reusable on any project, from the time you work with images in jpeg format (which format most common with digital photography) and your server supports GD2.

Solve 500 Internal Server Error on Magento Installation

If you are installing Magento directly on your server, then you may get some errors while opening the installation wizard on your browser, i.e, 500 INTERNAL SERVER ERROR. Its mainly because of the wrong FILE PERMISSIONS.
The best way to solve this issue is here,

1. Download Magento Cleanup Tool
2. Please open that link then create that file  magento-cleanup.php to the root directory where Magento is installed.
3. Browse to




Please create the file  magento-cleanup.php  insert that code



## Function to set file permissions to 0644 and folder permissions to 0755

function AllDirChmod( $dir = “./”, $dirModes = 0755, $fileModes = 0644 ){
$d = new RecursiveDirectoryIterator( $dir );
foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
if( $path->isDir() ) chmod( $path, $dirModes );
else if( is_file( $path ) ) chmod( $path, $fileModes );

## Function to clean out the contents of specified directory

function cleandir($dir) {

if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != ‘.’ && $file != ‘..’ && is_file($dir.’/’.$file)) {
if (unlink($dir.’/’.$file)) { }
else { echo $dir . ‘/’ . $file . ‘ (file) NOT deleted!<br />’; }
else if ($file != ‘.’ && $file != ‘..’ && is_dir($dir.’/’.$file)) {
if (rmdir($dir.’/’.$file)) { }
else { echo $dir . ‘/’ . $file . ‘ (directory) NOT deleted!<br />’; }


function isDirEmpty($dir){
return (($files = @scandir($dir)) && count($files) <= 2);

echo “———————– CLEANUP START ————————-<br/>”;
$start = (float) array_sum(explode(‘ ‘,microtime()));
echo “<br/>*************** SETTING PERMISSIONS ***************<br/>”;
echo “Setting all folder permissions to 755<br/>”;
echo “Setting all file permissions to 644<br/>”;
AllDirChmod( “.” );
echo “Setting pear permissions to 550<br/>”;
chmod(“pear”, 550);

echo “<br/>****************** CLEARING CACHE ******************<br/>”;

if (file_exists(“var/cache”)) {
echo “Clearing var/cache<br/>”;

if (file_exists(“var/session”)) {
echo “Clearing var/session<br/>”;

if (file_exists(“var/minifycache”)) {
echo “Clearing var/minifycache<br/>”;

if (file_exists(“downloader/pearlib/cache”)) {
echo “Clearing downloader/pearlib/cache<br/>”;

if (file_exists(“downloader/pearlib/download”)) {
echo “Clearing downloader/pearlib/download<br/>”;

if (file_exists(“downloader/pearlib/pear.ini”)) {
echo “Removing downloader/pearlib/pear.ini<br/>”;
unlink (“downloader/pearlib/pear.ini”);

echo “<br/>************** CHECKING FOR EXTENSIONS ***********<br/>”;
If (!isDirEmpty(“app/code/local/”)) {
echo “-= WARNING =- Overrides or extensions exist in the app/code/local folder<br/>”;
If (!isDirEmpty(“app/code/community/”)) {
echo “-= WARNING =- Overrides or extensions exist in the app/code/community folder<br/>”;
$end = (float) array_sum(explode(‘ ‘,microtime()));
echo “<br/>——————- CLEANUP COMPLETED in:”. sprintf(“%.4f”, ($end-$start)).” seconds ——————<br/>”;