Let's assume you have an array like this with the sku and prices.
$prices = array(
'sku1' => '12.99',
'sku2' => '15.00',
....
);
and you only need to change the price for store view 2.
Here is a fast way to do it.
Since the price can be global or has the website scope, you will also need to change the price for all the store views in the same website as the store view with id 2. The next script will do that for you, just make sure that prior to running it, you set the price scope to 'website'.
$storeId = 2;
$idsByPrice = array();
foreach ($prices as $sku=>$price) {
$id = Mage::getSingleton('catalog/product')->getIdBySku($sku);
if ($id) { //if the product exists
if (!isset($idsByPrice[$price])) {
$idsByPrice[$price] = array();
}
//group all skus by price so you will have less updates.
$idsByPrice[$price][] = $id;
}
}
//now you have an array of product ids grouped by price
//$idsByPrice = array(
// '12.99' => array(2,3,7,12),
// '15.00' => array(9,44,22),...
//)
foreach ($idsByPrice as $price=>$ids) {
Mage::getSingleton('catalog/product_action')->updateAttributes(
$ids, //ids to update
array('price'=>$price), //attributes to update
$storeId //store view to update the attribtues
);
}
Include Mage.php
at the top of the script and run it. back up your db first, just in case. And your indexes may need rebuilding when you are done.
I uploaded the .csv file and after that re-indexed all Indexes and then it was working as expected and the prices were updated so all good.
So I recommend
1) Make sure your .csv file is consistent
2) Make a test run on your development site with re-indexing after the upload
3) Do the same steps on the live system, shouldn´t take too long for a few products, and I have split up my 3000 products in 3 parts so 1k products each time.
Best Answer
Here is the simple script that does the job for you (easiest & fastest approach):
For details please refer the article - http://www.blog.magepsycho.com/magento2-fastest-way-import-update-product-prices-bulk/
UPDATE
New module for importing all prices(regular, special, tier & customer group price) in Magento 2 has been released, please check it out:
https://www.magepsycho.com/magento2-mass-regular-special-tier-group-price-importer.html