Get Free Audit

What is SKU Number in Magento and How to Generate it?

Apr 25, 2019

13854 Andrey Litvin

What is SKU Number in Magento and How to Generate it?

In order to properly work with Magento online store, both developer and store admin should have extensive knowledge about SKU, what role does it play for Magento inventory management and how to configure it for the purposes of your online store. The following article is dedicated to all these aspects and explores the following aspects.

Table of contents:

What is SKU in Magento
Product ID vs SKU vs UPC in Magento
What does SKU consist of
How to change SKU in admin panel and in the database
Where is SKU placed apart from product pages
How to change the position of SKU

What is SKU in Magento

SKU stands for a Stock Keeping unit, and it is a unique identification code in alphanumeric format. It is assigned to every product in an online Magento store for inventory purposes and can identify a product according to its manufacturer, color or size options, price, etc. as well as its availability in stock. SKU is also used to create orders, shipping, and working with inventory. SKU can be used in several systems simultaneously: for instance, if the store is multilanguage, the name of the products in each language will be different, but the SKU will remain the same.

what is SKU

sku in admin

Product ID vs SKU vs UPC in Magento

Since SKU is not the only product identifier in ecommerce, confusion and misunderstanding may arise, especially when you are a novice online retailer. Therefore, I shall make clear the difference between the most common product identifiers – SKU, UPC and Product ID.

The product ID is a number in a numerical format, automatically assigned to the product at its creation. It serves as an internal identifier and is not visible to the customer. A product ID can not be manually changed and when the corresponding product is deleted, this ID will never be assigned to another product.

UPC stands for Universal Product Code and is commonly called barcode. UPC is a global system of 12 (in some cases 13) digits, created more than 40 years ago for trade tracking purposes. UPC is assigned to each trade item individually by a special organization GS1 and is aimed for external use – scanned at the points of sale, it allows to track an item at various points of its retail journey. UPC contains information that identifies product origin, manufacturer, price and so on.

SKUs, in their turn, are utilized solely for internal purposes of a store and are unique for each company. Also, SKU contains both numbers and letters, and for convenience sake, it is based on the product name and certain attributes (for instance, SKU for black Nike women running shoes in size 8 can be NIKE-WMN-BLK-8). The main purpose of this system is keeping track of one store’s inventory.

What does SKU consist of

SKUs consists of a set of numbers, letters, dashes and underscores. As a rule, SKUs consist of abbreviations of the product name and its most distinguishing features. For example, the SKU for the product “Mountain bike” green with wheels of 27 inches could be the following: BIC-MT-27-GRN.

Dashes and underscores are usually used for semantic separation of such abbreviations, like you could have already understood from the example above. Without the separators, SKU will be complicated to comprehend (for instance, it would have been BICMT27GRN, not BIC-MT-27-GRN).

When creating SKU number, avoid using spaces and special characters (such as “*”, “>”, “&” and others). It is also not recommended to use only numbers, as they are not as descriptive as words; that is more, such number can get easily confused with product UPC.

In Magento 2, the maximum length of SKU is 64 characters. If you try to enter SKU longer than 64 characters in the Admin panel, you will get the message
“Please enter less or equal than 64 symbols.”

If you are having troubles with creating numerous SKU numbers yourself, you can always use a SKU number generator. There is a great variety of online SKU generators available on the web, and they all share pretty similar logic – you need to input product name and its main attributes, and the tool will output a unique SKU.

How to change SKU in admin panel and in the database

To change SKU in the admin panel, log into your back office and navigate to the product you want to change SKU for. Each edit menu page has a SKU field that you can edit and press Save to keep the changes.

sku magento

There is another method of changing product SKU is in the database. For this, find the tables catalog_product_entity, sales_order_item, sales_quote_item and change product SKUs there. Make sure that the SKUs for a particular product does not differ in all these tables.

what is sku Magento

Where is SKU placed apart from product pages

By default, Magento 2 SKU is positioned on the product page, on the product comparison page, in order history, in invoices and in delivery pages.

sku example

When you compare two products in Magento store, their SKUs are also placed into the comparison table.

product comparison sku

How to change SKU position

At times a necessity arises to change the location of SKU on the product page. This can be done programmatically.

First of all, you should find out which file is responsible for displaying the SKU on the product page. The following layout file for the “catalog_product_view.xml” of the Catalog module is responsible for this:

Bear in mind that in order to change this file you need to copy it to the folder with your theme. It is not advised to change the original module files; instead, always copy them into your theme. Otherwise, if you update the module, your changes may be deleted:

In this file we can find a block with the name “”. This block also adds SKU to the product page. It looks the following way:

In order to move any block or container to another place on the page, you need to add the following code to the layout file of your theme:


<element_name> – the name of the element that we want to move (the element can be both a block and a container);
<destination_name> – the name of the element that we want to move our element into.

For example, in order to move the SKU before the product name, you need to use the following code in the layout catalog_product_view.xml file of your theme:


before – is an argument that indicates before which element at the destination to insert a portable block (in this case, “-” means that the block will be added before all the elements at the destination). Instead of “before” you can use “after”, which indicates after which element at the destination to insert the portable block.

As a result, SKU will be displayed before the product name.

sku change position

How to remove SKU from the product page

In order to remove the SKU from the product page, add the following code in the layout catalog_product_view.xml file of your theme, mentioned above:


name – the name of the block that we delete.

As a result, SKU will be deleted from the product page.

Vlad Yunusov

Partner With Us

Let's discuss how to grow your business. Get a Free Quote.
Talk to Vlad


How can I get SKU on the product page via layout?

You can add SKU to the product page using the following block in the layout file catalog_product_view.xml:

How to autogenerate SKU?

In order to auto-generate SKU, log in to the admin panel and navigate to

STORES -> Settings -> Configuration

Follow this path

CATALOG -> Catalog -> Product Fields Auto-Generation

To the “Mask for SKU” field that specifies the template according to which SKU will be formed:

Mask for SKU

Magento ->getSku() or getData(‘sku’) returns empty string

In order to add SKU to the category page for each product in the list, you must edit the following product list template file:

Copy this file to your theme folder.:

Use the following code to add SKU:

For example, you can add SKU after the product name in the list (in this file after the block with the class “product name product-item-name”):

sku in catalog magento

Wrapping it up

This article provided a complete overview of what is SKU in Magento, what it consists of, how to work with it and configure it. If you have any questions or comments, you are welcome to leave them down below.

Extensions for Magento 2

Magento Extensions by BelVG

Take your online store to the next level

Download here
Vlad Yunusov
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Vlad


Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *