Last active
June 12, 2026 08:34
-
-
Save twesolowski/09ce7a3e31c3c9503344abe8a58e29f7 to your computer and use it in GitHub Desktop.
PrestaShop regenerate product rewrites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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