0

I have recently setup a new international store with english product titles, whereas my product titles are originally in danish. Now I need to regenerate all URLs for this store view, to use the english title instead of the old danish ones that are currently.

I order to do this, I guess I have to remove all existing URLs from this store and let magento create new ones. But what is the easiest way of doing this for around 2k products?

Thanks!

1 Answer 1

3

Here's a number of options:

  1. Update the URL keys the same way you updated the product titles.
  2. Export, transform values, import.
  3. Unset the URL keys programmatically and have them regenerated automatically.

While the former are rather self-explanatory, this is how the scripted approach looks like:

$collection = Mage::getModel('catalog/product')->getCollection(); $collection->setStoreId($newStoreId); $collection->addStoreFilter($newStoreId); $collection->addAttributeToSelect('*'); foreach ($collection as $product) { $product->setStoreId($newStoreId); // disable adding entries to url rewrite rules (optional): $product->setSaveRewritesHistory(false); // if there are already url keys on store scope: $product->unsUrlKey(); // otherwise, if the new store uses default values from parent scope: $urlKey = $product->formatUrlKey($product->getName()); $product->setUrlKey($urlKey); } $collection->save(); 

By default, URL rewrites are added to the system. You can optionally turn that behaviour off.

Unsetting the URL key will only have effect if the product already has a URL key in the new store scope. If the product pulls its URL key from a website or default scope, the new URL key must be set explicitly.

3
  • Yeah, option 3 is what is was looking for. I will try using your code snippet. Thanks! Commented Sep 15, 2015 at 8:23
  • I was just about to do this, but then I realized.. Will this create URL forwards for the old URLs? Commented Sep 29, 2015 at 13:47
  • Answer updated to include information on catalog url rewrites. Commented Oct 30, 2015 at 10:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.