Clearing URLs in Magento

I installed a magento installation for the store owner who added his own products. Unfortunately, he did not understand the key field of URl. When he duplicated the product, each product now has the same URL with the extension / product -1234.html, the next one is / product -1235.html. Since he has almost 2 thousand Products, it will be a hassle to manually configure all URL keys. Is there a way to clear this in purple (or directly on the database) without destroying the store. It seems that if I delete one URL key, the purple auto-generator will generate one, which is suitable for me.

Edit: Ok, so I found a way to reset the URL key by clearing certain fields in the database table (catalog_product_entity_varchar), but now I need Magento to create new ones using the product name. Any ideas?

Thanks.

+4
source share
2 answers

Here's a quick one that isn't even tested. It may take a long time if there are many products, but it will also update the dubbing records at the same time. Copy this to the .php file in the root of your site and execute it.

<?php require 'app/Mage.php'; Mage::app(); $products = Mage::getModel('catalog/product')->getCollection(); foreach ($products as $product) { $product->setUrlKey($product->getSku()) ->save(); } 
+6
source

Finally, this has been fixed with the following code based on the clockworkgeek examples. Thanks for this!

 <?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++; } 
+6
source

All Articles