Paypal gateway has rejected request magento solved

11:49 AM 0
How To Fix Paypal gateway has rejected request. The totals of the cart item amounts do not match order amounts (#10413: Transaction refused because of an invalid argument. See additional error messages for details).

Solution:

The first step is to copy the Abstract.php file from app/code/core/Mage/Paypal/Model/Api/ 
to 
app/code/local/Mage/Paypal/Model/Api/. 
You can make these changes directly to the core file if you really have to, but it's not recommended. 




//Find the

 _exportLineItems function

//(line 390 in my version 1.9)


//Before the foreach ($items as $item) { (around line 412) add this:

$running_total = 0;

//Before the $request[sprintf($privateFormat, $i)] = $value; (around line 423) add this:

if ($publicKey == 'amount') {
    $running_total += $value;
}

//Before the return $result; (around line 427) add this:

// Check ITEMAMT. If different to running total, offset prices
if ((isset($request['ITEMAMT'])) && ($request['ITEMAMT'] > 0)) {
    if ($running_total <> (float) $request['ITEMAMT']) {
        $difference = ($running_total - (float) $request['ITEMAMT']);
        // Apply difference to first product.
        $request['L_AMT0'] = (string) ((float) $request['L_AMT0'] - $difference);
    }
}

How to Remove Magento Pricing For Options in Dropdown

11:08 AM 2



Sometimes our customers want to remove price in drop down from product custom option in Magento.
So here is easy way to do this.



1- Go to the following path


2- Open the following/select.php file.









3- Comment the  $priceStr.




That's It..
Enjoy.. Happy Coding..

How to Change Database Settings In Magento

2:32 PM 0

How to change Magento Database Settings.

1- Go to magento/app/etc/local.xml (see blow picture)




2- Open local.xml then you will find the below code.



3- Enter Username: Enter Username of database.
4- Enter Password: Enter Password of database.
5- Enter Database Name: Enter Name of database.
6- Now Save and Refresh the page..
7- Enjoy

Magento Get Current Product ID

3:44 PM 0
How to get current product id in magento. Blow code will display currently loaded product id..



<!-- Magento Current Product Id -->
        <?php $current_product_id = $this->getProduct()->getId(); ?>

If above code not working then try below code..
<!-- Magento Current Product Id -->
<?php 
$current_product_id = Mage::registry('current_product')->getId();
?>

Codeigniter Display Last Query

2:03 PM 0

The following code return the last query that was running in codeigniter.
Sometimes we want to display which query was currently running. For this purpose just echo
the query then it will display the last query that was run.


<!-- Codeigniter last Query -->
   <?php 
    $last_query = $this->db->last_query();
    ?>
<!-- It will produce: SELECT * FROM table WHERE.... -->