Shopkeeper created configurable products by duplicating existing products and did not change the product URLs to match the product names. The shop is also a multilingual shop and different languages are made as store views.
This all lead to situation where the duplicated products had wrong url keys.
I found this code that could be added to a new .php file and run on the server and that was a solution for ONE store view:
<?php
require 'app/Mage.php';
Mage::app();
$amount = 0;
$model = Mage::getModel('catalog/product');
$products = $model->getCollection();
foreach ($products as $product) {
$model->load($product->getId());
$product->setUrlKey($model->getName())->save();
set_time_limit();
$amount++;
}
That code changed the product url keys to match the product names, but it only worked for one store view.
My question is: how do I change the product url keys for the other store views in other languages?
UPDATE! The solution was easy: in the frontend just change to the next store view and run the new .php file in that view also.