How to remove Junk Characters from Product Description in Magento for Google Base

At the time of submitting Google base approved in Magento. Sometimes it generates error message like “Expected response code 200, got 400. Type: data. Field: description. Reason: There is a problem with the character encoding of this attribute.” because in the Product Description some Junk Characters have used which doesn’t support by Google Base. So, it generates the errors.

Step: – 1 First of all create php file for getting product description and removes the escape character from product description. Copy below code and paste into PHP file.

require_once './app/Mage.php';

// Get the current store id
$storeId = Mage::app()->getStore()->getId();

// Get the Configurable Product only

$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('type_id', array('eq' => 'configurable'));

// Loop for getting all Configurable Product one by one

foreach ( $products as $productModel )

$_product = Mage::getModel('catalog/product')->load($productModel->getId());

//do something useful with this $_product object

$desc= $_product->getDescription();
$id= $_product->getId();

echo $id; echo "&nbsp;&nbsp;";
$newdesc = iconv('UTF-8', 'ASCII//TRANSLIT', $desc);
echo "complete"; echo "<br/>";

Step: – 2 Put this file on the Root Directory of your Magento site and run it manually.
For ex: –

Step: – 3 After completion of the process it will display Product ID which Description have been successfully changed.

Posted in Magento. 1 Comment »

One Response to “How to remove Junk Characters from Product Description in Magento for Google Base”

  1. Pete Says:

    was banging my head against the wall as to why this was happening. thanks for the info.

Speak Your Mind

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: