I found a query so I can mass change something in my products description. With this script:

$collection = Mage::getModel('catalog/product')
    //->addFieldToFilter('') //Use filters to select a specific group of products

foreach($collection as $product) {
    $desc = $product->getDescription();
    // Remove parts of your description here

But this is for remove a part of description.

I want something to change a part of the description with something new. The scenario is that inside the description has some directs links like:

<a href="http://address.html"> 

and must be changed like this:

<a href="{{store url='address.html'}}">

But I don't have the knowledge to fix this query to select these descriptions in 2 different languages and replace the url with the new one. Can anyone please help?

1 Answer 1


With in following code block

foreach($collection as $product) {
    $desc = $product->getDescription();
    // use preg_replace to store the new description in new variable e.g.
    // in pattern you can use regex to match desired URL
    // in replacement provide the new URL 
    $newDescription = preg_replace($pattern, $replacement, $desc);

Your Answer

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

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