0

Recently a developer imported all products prices as without VAT. Problem is the prices are including VAT.

We want to remove 25% VAT from all products in our Magento shop. My first thought is to export all the products, open it in Excel and correct the prices, save it and import the prices.

Do you have an easy/better way to do it?

1
  • You want to add price for all product right
    – Magento 2
    Dec 3 '15 at 12:30
1

You need to have the correct settings in your configuration.

Look under System/Configuration/Sales/Tax/Calculation

If you write your product prices including taxes, then these options should be set to yes.

1
  • Also I added VAT settings under "Sales" in the menu.
    – Cudos
    Dec 3 '15 at 19:56
1

Add bellow script in file (test.php) on magento root and run your browser

<?php
require_once('app/Mage.php');
Mage::app('default');

class ABDUL
{
    public function index()    
    {
        echo '<pre>';
        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->addAttributeToSelect('price');
        $collection->addAttributeToSelect('visibility');
        if(count($collection)) {
            foreach($collection as $product) {
                try {
                    $odlPrice = $product->getPrice();
                    $newPrice = $odlPrice -($odlPrice*25/100);
                    $product->setPrice($newPrice);
                    $product->setVisibility($product->getVisibility());
                    $product->setId($product->getId());
                    $product->save();
                    Mage::log('product sku: '.$product->getSku().' old price : '.$odlPrice.'new price : '.$newPrice,'product_price_update.log');
                } catch (Mage_Core_Exception $e) {
                   $e->getMessage();
                }
            }
        }
    }
}

$obj = new ABDUL();
$obj->index();
?>

Note : take your database backup first

1
  • I can use your code for another problem I have, thanks!
    – Cudos
    Dec 3 '15 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.