Batch change descriptions programmatically in Magento

This is a simple script to bulk update Magento products’ descriptions quickly and easily. It takes as its input a two column CSV, which simply has the product SKU in the first column, and the new description in the second column – this CSV is uploaded to the web root of your site, along with the script file.

Script To Bulk Update Magento Products’ Descriptions

require_once 'app/Mage.php';

Change the name of the CSV file in the next line to match your own CSV :

$file_handle = fopen("descriptions.csv", "r");

The script then loops through the file line by line, gets the SKU from the first column and the new description from the second. It then tries to load the product – if it’s successful in doing so then it sets the new description as the product’s description, then saves the products and reports success.

while (!feof($file_handle) ) {
	$line_of_text = fgetcsv($file_handle, 1024);
	$productSku = $line_of_text[0];
	$newDescription = $line_of_text[1];
	$simpleProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$productSku);
	if($simpleProduct) {
		echo "Updated product " . $productSku . "<br>";

Run the file through your browser or – better still – over SSH. The latter is advised if you’ve got a large number of descriptions to amend, as it’s likely that your browser would time out.