清除Magento中的URL密钥 [英] Clearing URL keys in Magento
问题描述
我已经为添加了自己的产品的店主设置了magento安装.不幸的是,他不了解URl关键字段.当他复制产品时,每个产品现在都具有相同的URL,并带有递增的编号/product-1234.html,下一个是/product-1235.html.由于他拥有近2k的产品,因此手动调整所有url键会很麻烦.有什么方法可以在不破坏商店的情况下在magento(或直接在DB上)清除此问题.看来,如果我删除一个URL键magento会自动生成一个,这对我来说很好.
I've setup a magento installation for a shopowner who has added his own products. Unfortunataly he didn't understand the URl key field. As he duplicated the product, each product now has the same URL with a incrementing number /product-1234.html, next one /product-1235.html. Since he has almost 2k products, it will be a hassle to manually adjust all the url key's. Is there some way to clear this in magento (or straight on the DB) without ruining the shop. It seems that if I delete one URL-key magento auto-generates one, which is fine for me.
好的,因此,我找到了如何通过清除数据库表(catalog_product_entity_varchar)中的某些字段来重置URL密钥的方法,但是现在我需要Magento使用产品名称来创建新的字段.有什么想法吗?
Okay, so I've found how I can reset the URL key's by clearing certain fields in a database table (catalog_product_entity_varchar), but now I need Magento to create new ones using the product name. Any ideas?
谢谢.
推荐答案
这里是一个未经测试的快速工具.如果有很多产品,可能会花费很长时间,但也会同时更新重写记录.将其复制到网站根目录中的.php文件中并执行.
Here's a quickie that isn't even tested. It might take a long time if there are many products but it will also update the rewrite records at the same time. Copy this into a .php file in your site's root 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();
}
这篇关于清除Magento中的URL密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!