Skip to content

Instantly share code, notes, and snippets.

@twesolowski
Last active June 12, 2026 08:34
Show Gist options
  • Select an option

  • Save twesolowski/09ce7a3e31c3c9503344abe8a58e29f7 to your computer and use it in GitHub Desktop.

Select an option

Save twesolowski/09ce7a3e31c3c9503344abe8a58e29f7 to your computer and use it in GitHub Desktop.
PrestaShop regenerate product rewrites
<?php
require_once __DIR__ . '/config/config.inc.php';
$db = Db::getInstance();
$rows = $db->executeS("
SELECT id_product, id_lang, id_shop, name
FROM " . _DB_PREFIX_ . "product_lang
WHERE name IS NOT NULL AND name != ''
");
foreach ($rows as $row) {
$id_product = (int)$row['id_product'];
$id_lang = (int)$row['id_lang'];
$id_shop = (int)$row['id_shop'];
$name = $row['name'];
$rewrite = Tools::link_rewrite($name, $id_lang);
if (!$rewrite) {
continue;
}
$db->execute("
UPDATE " . _DB_PREFIX_ . "product_lang
SET link_rewrite = '" . pSQL($rewrite) . "'
WHERE id_product = $id_product
AND id_lang = $id_lang
AND id_shop = $id_shop
");
}
echo "DONE\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment