-1

We did something wrong when uploading our products to our database. SKU number ended up in description, and description ended up in SKU.

It is around 1.000 products, so manually doing this is not an option. Also, this is an old error that didnt get noticed until now, so many of the products have order history on them by now.

Is there a way to switch these fields?

1 Answers1

0

Try to identify the product ids that have this problem.
If all of them are in this situation that it's easier.
The idea is to first get an all the products that need modifying If you can get them manually do this:

$ids = array(1,3,5,6,7,8, ...);
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('description')->addAttributeToFilter('entity_id', $ids);

if all the products need modifying do this:

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('description');

After you have all the ids run this script:

foreach ($products as $product) {
    Mage::getSingleton('catalog/product_action')->updateAttributes(
        array($product->getId()), //id to update
        array(  //values to update
            'sku' => $product->getDescription(),
            'description' => $product->getSku()
        ),
        0 //store id
    );
}
Marius
  • 15,148
  • 9
  • 56
  • 76