I am facing an error while updating prices of all product eg. i have 2000 products it will update the price of some of the product and rest of it will not update

i use to follow this link to update the price http://www.blog.magepsycho.com/updating-product-prices-in-magento-in-easier-faster-way/

  • What is the error? Commented Feb 2, 2017 at 1:43
  • Error is it shows there is no product code with this sku code but actually it exist
    – Akash
    Commented Feb 2, 2017 at 1:44
  • Try removing header row, SKU and price from CSV. Also first check with one or two entries in CSV file. If it's working, then go with all records. Commented Feb 2, 2017 at 1:49
  • but it updates the price of some of products.
    – Akash
    Commented Feb 2, 2017 at 1:52
  • Still it shows the same error after removing the sku and price field
    – Akash
    Commented Feb 2, 2017 at 1:56

2 Answers 2


If you are sure that the SKU exists, you can update your code like below and then check.

function _updatePrices($data){

    $connection     = _getConnection('core_write');

    $sku            = trim($data[0]);

    $newPrice       = $data[1];

    $productId      = _getIdFromSku($sku);

    $attributeId    = _getAttributeId();


    $sql = "UPDATE " . _getTableName('catalog_product_entity_decimal') . " cped

                SET  cped.value = ?

            WHERE  cped.attribute_id = ?

            AND cped.entity_id = ?";

    $connection->query($sql, array($newPrice, $attributeId, $productId));


It happens sometimes that there is a blank space in SKU value in CSV.

  • Still its not working i tried your solution still it shows that the sku code is not exist but actually its there in csv file and it also shows in magento admin panel -> cataloge-> product
    – Akash
    Commented Feb 2, 2017 at 2:10
  • Its working now the same issue as you said it takes the blank space is there so thanks you very much for your quick response
    – Akash
    Commented Feb 2, 2017 at 2:12
  • If the solution worked for you then please accept the answer so it can be helpful to others facing the same issue. Commented Feb 2, 2017 at 2:15
  • One more thing i need to ask is how can i remove the extra space with sku code in cataloge-> product-> sku.
    – Akash
    Commented Feb 2, 2017 at 2:57

Here is answer to your second question.


$mageFilename = 'app/Mage.php';

require_once $mageFilename;


ini_set('display_errors', 1);



Mage::register('isSecureArea', 1);




    $collection = Mage::getModel('catalog/product')->getCollection ();
    foreach($collection as $product){ $sku = trim($product->getSku());

Create a new file in your Magento root folder and put this code in it. Then run file.

  • In the same file do i need to edit ?
    – Akash
    Commented Feb 2, 2017 at 3:15
  • Please check updated answer Commented Feb 2, 2017 at 3:19
  • So that will remove the all white space around the sku code right ?
    – Akash
    Commented Feb 2, 2017 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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