Clearing URL keys in Magento

Clearing URL keys in Magento

July 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Clearing URL keys in Magento

Clearing Magento URL Keys: A Developer’s Guide

As a seasoned developer working with Magento e-commerce platforms, I often encounter situations where clients or other developers have accidentally duplicated products without updating the URL Key field correctly. This leads to inconsistencies in your site’s URLs, which can negatively impact search engine optimization and customer experience.

Let me walk you through two common scenarios and provide practical solutions for clearing these URL keys in Magento while ensuring the integrity of your shop remains intact.

Scenario 1: Clearing Existing URL Keys

When your client has manually entered incorrect or duplicate URL keys for multiple products, it becomes crucial to reset them back to their default state. This process involves directly interacting with the database, as Magento’s built-in interface doesn’t provide a mass-clear option for this field.

To clear the existing URL keys:

  1. Backup your database before making any changes.
  2. Connect to your MySQL database using your preferred client (e.g., phpMyAdmin or a SQL client).
  3. Locate the catalog_product_entity_varchar table, which stores the product attributes data.
  4. Execute the following SQL query to clear the contents of the url_key column for all products:
UPDATE catalog_product_entity_varchar
SET value = ''
WHERE attribute_id IN (
  SELECT entity_id FROM eav_attribute WHERE attribute_code = 'url_key'
);

This query targets only the catalog_product_entity_varchar table and sets the value of the url_key column to an empty string for all products.

Scenario 2: Generating New URL Keys Based on Product Names

After clearing the existing URL keys, you’ll want Magento to generate new ones automatically using the product names as a base. This can be achieved by utilizing Magento’s built-in functionality for auto-generating URL keys based on specific rules.

To configure Magento to create URL keys from product names:

  1. Log in to your Magento admin panel.
  2. Navigate to Stores > Configuration and select the desired scope (usually “Default Config”).
  3. In the left menu, click on Catalog > Catalog > Product Attributes.
  4. Find the row for the url_key attribute in the list.
  5. Set the Generate URL Key Automatically option to “Yes”.
  6. Choose the appropriate Template for URL key (e.g., “%product%”) based on your desired format.
  7. Click the Save Config button at the top right of the page.

By following these steps, Magento will now automatically generate new URL keys for each product during the next indexing cycle or when you save changes to a product’s name. The system will use the specified template and replace placeholders with actual data from the product details (e.g., SKU, name, etc.).

Conclusion

Clearing existing URL keys in Magento requires direct interaction with the database using SQL queries, ensuring that your shop remains functional during the process. After clearing the keys, you can leverage Magento’s built-in configuration options to generate new URL keys automatically based on the product names.

Remember to always backup your database before making any changes and test the updated URLs thoroughly after the process is complete. Keeping your product URLs consistent and well-structured significantly improves navigation for both customers and search engines alike.

If you’re looking for professional assistance with Magento development or need guidance on optimizing your e-commerce platform, feel free to reach out to Laravel Company. Our team of experienced developers is ready to help you resolve complex issues like URL key clearing and ensure the success of your online venture.

Catalog Database Performance Admin

Our network