PrestaShop Documentation, PrestaShop Tutorials

Prestashop how to hide product attributes values in the URL

In PrestaShop, product attribute values (like size, color) appear in the URL because of combinations and the rewrite (friendly URL) system.

Example URL:

/t-shirt/12-tshirt-blue-xl.html

Here blue-xl comes from attribute values.

If you want to hide attribute values from the URL, you have several options:


✅ Method 1: Disable Combination Rewrite in Core (Recommended Safe Override)

By default, PrestaShop appends combination names to the URL when:

  • Product has combinations
  • Friendly URL is enabled

🔹 Solution: Override Link.php

  1. Go to:
/override/classes/Link.php

If not exist, create it.

  1. Override getProductLink() and remove combination rewrite part.

Example:

class Link extends LinkCore
{
    public function getProductLink(
        $product,
        $alias = null,
        $category = null,
        $ean13 = null,
        $id_lang = null,
        $id_shop = null,
        $ipa = 0,
        $force_routes = false,
        $relative_protocol = false,
        $add_anchor = false,
        $id_product_attribute = 0,
        $extra_params = array()
    ) {
        $id_product_attribute = 0; // Force remove combination
        return parent::getProductLink(
            $product,
            $alias,
            $category,
            $ean13,
            $id_lang,
            $id_shop,
            0,
            $force_routes,
            $relative_protocol,
            $add_anchor,
            0,
            $extra_params
        );
    }
}
  1. Clear cache:
Advanced Parameters → Performance → Clear Cache

Now URLs will be:

/t-shirt/12-tshirt.html

No attribute values.


✅ Method 2: Disable Friendly URL (Not Recommended for SEO)

Go to:

Shop Parameters → Traffic & SEO

Disable:

Friendly URL = No

But this gives:

index.php?id_product=12&controller=product

❌ Not SEO friendly.


✅ Method 3: Remove Combination Anchor Only

Sometimes attribute is not in URL but after #:

/t-shirt.html#/2-size-xl

That part is handled by JavaScript.
To remove it:

Edit:

themes/your-theme/assets/js/product.js

Remove or modify:

window.location.hash = ...

✅ Method 4: Force Canonical URL (Best for SEO)

Instead of hiding completely, you can:

  • Keep combinations working
  • Force canonical to base product

Edit product.tpl:

<link rel="canonical" href="{$link->getProductLink($product.id_product)}">

This keeps SEO clean.


⚠️ Important Warning

If you remove combination from URL:

  • Google indexed combination URLs may break
  • Price updates via combination may not work correctly
  • Some themes rely on id_product_attribute

Always test on staging site first.


🎯 Best Practice (Recommended for You)

Since you are working on PrestaShop speed optimization, I recommend:

✔ Keep friendly URLs
✔ Remove combination rewrite via override
✔ Add canonical to base product
✔ Keep combinations working with JS


 

About zohaibk

We develop useful addons for #E-Commerce and #CRM software to provide extra features.#PrestaShop,#Magento,#SugarCRM,#Vtiger & #Android #apps
View all posts by zohaibk →