Magento Page Title - include SKU as well as product name

Magento Page Title - include SKU as well as product name

August 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Page Title - include SKU as well as product name

Enhancing Magento Product Page Titles: Including SKU and Product Name

As an e-commerce developer, crafting effective page titles is crucial for both user experience and search engine optimization (SEO). In Magento, by default, the product details page title only displays the product name. However, you might want to include the SKU number as well to provide more contextual information.

Let’s dive into how to achieve this in your Magento store.

Understanding the Default Page Title Structure

Before making changes, it’s essential to understand the default structure of a Magento product page title. By default, the page title is set based on the config.xml files located under app/code/core/Mage/Catalog/etc/.

The default configuration looks like this:

<page>
    <title_replace>
        <product>Product Name</product>
    </title_replace>
</page>

This means that Magento only includes the product name in the page title.

Modifying the Page Title to Include SKU

To include both the SKU and the product name, you’ll need to override the config.xml file. Here’s a step-by-step guide:

  1. Navigate to your theme directory under app/design/frontend/<your_package>/<your_theme>.

  2. Create a new folder named etc, if it doesn’t exist.

  3. Inside the etc folder, create another folder called modules.

  4. In the modules folder, create a new XML file named Mage_Catalog.xml.

  5. Open the Mage_Catalog.xml file and add the following code:

<config>
    <global>
        <models>
            <catalog>
                <rewrite>
                    <product>LaravelCompany\MagentoProductTitleRewrite\Model\Product</product>
                </rewrite>
            </catalog>
        </models>
    </global>
</config>

This code tells Magento to use a custom model for the Mage_Catalog package.

  1. Next, create a new folder named app/code/local/LaravelCompany/MagentoProductTitleRewrite/Model (replace ‘LaravelCompany’ with your actual namespace).

  2. Inside the Model folder, create a file called Product.php.

  3. Open the Product.php file and add the following code:

<?php

namespace LaravelCompany\MagentoProductTitleRewrite\Model;

class Product extends \Mage_Catalog_Model_Product
{
    public function getName()
    {
        $name = parent::getName();
        return $this->getSku() . ' - ' . $name;
    }
}

This code overrides the getName method to include both the SKU and the product name.

  1. Save all files, clear your Magento cache, and refresh your store front-end.

Conclusion: Enhancing SEO with Custom Page Titles

By following these steps, you’ve successfully modified your Magento page titles to include both the product SKU and the product name on the product details page. This approach provides a more comprehensive title that can help improve user navigation and potentially boost your site’s relevance in search engine results.

Remember, while this is a simple example, it demonstrates how you can leverage Magento’s flexibility for customization. For more advanced SEO strategies, consider integrating tools like Yoast SEO or using services provided by Laravel Company to optimize your e-commerce platform.

Don’t forget that small details like this can make a significant difference in the user experience and search engine performance of your Magento store. Keep exploring and optimizing!

Happy coding!

Catalog Performance Extensions Themes

Our network