How to Add Magento Product Attributes and Attribute Sets?

How to Add Magento Product Attributes and Attribute Sets?

As an e-commerce business owner, providing customers with detailed, accurate product information is critical. It drives sales and enhances their shopping experience.

Magento offers a flexible solution for managing product attributes. It is crucial in helping customers find, compare, and choose the right products.

In this tutorial, we will explore Magento product attributes. We’ll guide you through creating and managing them effectively.

We will cover everything from product attributes basics to more advanced topics. It includes creating custom attributes and working with attribute sets. You can use the attributes for promotional purposes.

By the end of this tutorial, you’ll know how to manage product attributes in your Magento store effectively.

What are Magento Product Attributes?

What are Magento Product Attributes

Product attributes in Magento are the specific characteristics that help define products in your online store.

It provides customers with detailed information about each product. The attributes help them make informed purchase decisions.

Attributes also serve as building blocks for creating advanced search functionality and layered navigation. It is used as a criterion for product comparisons, enabling a smoother shopping experience for your customers.

By managing product attributes effectively, you can enhance your products' -

  • Organization
  • Product presentation
  • Discoverability.

It ultimately leads to increased sales and improved customer satisfaction.

The main uses of product attributes include-

  • Clearly defining product data.
  • Filter and search the products for easy navigation.
  • Compare products in reports
  • Use for Magento promotions.

Examples of Product Attributes

You can create and manage many types of product attributes in Magento. Here are some common examples:

  • Color Describes a product's color, enabling customers to filter products based on their preferred hues.

  • Size Specifies a product's dimensions or size variations. Customers can choose the right fit for their needs.

  • Material Defines the materials used in manufacturing a product. It is essential for customers with specific preferences or requirements.

  • Brand Indicates the manufacturer or brand of a product. Customers can find and select items from their favorite companies.

  • Weight Provides the weight of a product, which is essential for customers considering shipping costs. It is also useful for product handling requirements.

  • Price Displays the cost of a product, assisting customers in finding items within their desired price range.

  • SKU Assigns a unique identifier to each product. It is easy to manage inventory and product tracking.

  • Warranty Indicates the warranty period or terms offered by the manufacturer. Customers get information about the quality and durability of their purchases.

  • Ratings & Reviews Showcases customer feedback, ratings, and reviews. Potential buyers can make more informed decisions.

  • Availability Displays the stock status of a product. It informs whether an item is in stock, out of stock, or available for pre-order.

  • Promotion Highlights any special offers, discounts, or promotions that apply to a product. It encourages customers to take advantage of limited-time deals.

  • Custom Attributes In addition to the standard attributes, Magento allows you to create custom attributes. It is created for your specific products or industry. For example, you might create attributes for certifications, allergens, or environmental impact. It caters to your target audience's specific needs and preferences.

Types of Product Attributes in Magento 2

In Magento 2, there are two main product attributes:

  • System attributes
  • Custom attributes.

1. System Attributes

System attributes are the default attributes provided by Magento 2. It offers proper functioning of the platform and cannot be deleted.

These attributes serve various purposes, such as managing product information, catalog navigation, and sorting.

Some common examples of system attributes include:

  • Name: The product's name appears on product pages and search results.

  • SKU: The unique stock-keeping unit used to identify a specific product.

  • Price: The product's cost, displayed on product pages. It is also used in calculating cart totals.

  • Weight: The product's weight may be used for shipping calculations.

  • Status: Indicates if the product is enabled or disabled within the store.

  • Visibility: This shows where the product will appear on the website. For example, catalog pages, search results, or both.

2. Custom Attributes

The store owner can easily create custom attributes. It adds specific product information not included in the default system attributes.

They allow you to provide additional details about your products. It makes it easier for shoppers to find exactly what they want.

Custom attributes can be used for various purposes, such as:

  • Show unique product features
  • Allow product comparisons - size, color.
  • Enhance search and navigation

To create a custom attribute, navigate to the Magento 2 admin panel and follow these steps:

  • Go to Stores > Attributes > Product.

  • Click the "Add New Attribute" button.

  • Fill in the required information, such as attribute code, input type, and default label.

  • Configure the advanced attribute properties and storefront properties as needed.

  • Save the attribute.

Once you've created a custom attribute, you can assign it to the appropriate attribute set. Then you can add it to your product pages.

Creating Custom Product Attributes in Magento.

Creating custom Magento product attributes is a linear process. It enables you to provide more information about the products. This section will give you the steps to create custom product attributes in Magento 2.

1. Accessing the product attributes page

Log in to your Magento 2 admin panel. Navigate to Stores > Attributes > Product.

  • Adding new attributes

  • Click the "Add New Attribute" button. It is the top right corner of the product attributes page.

Adding New Custom Attributes in Magento Admin Panel

2. Properties Tab Settings

A. Catalog input type:

Select the desired input type for the attribute. It includes -

  • Text Field: Enter text in a single-line input field

  • Text Area: Multi-line input area for entering text directly or through a WYSIWYG Editor

  • Text Editor: Incorporate a WYSIWYG Editor into custom fields.

  • Date: Select or manually input the Date & Time from a calendar

  • Yes/No: Toggle button with two pre-defined options: Yes and No

  • Dropdown: Choose one option from a drop-down list

  • Multiple Select: Create price fields; system configuration determines the Magento currency.

  • Media Image: An additional image type along with Base, Small, and Thumbnail.

  • Fixed Product Tax: Set FPT rates as per local requirements

  • Visual Swatch: Configurable product images displayed per visual option (e.g., color)

  • Text Swatch: Configurable product images displayed per text option (e.g., size)

This determines how the attribute will be displayed and interacted with on the front end.

Learn how to Set up Magento 2 Configurable Swatches

B. Attribute code and default value:

Enter a unique attribute code in the field, If applicable, a default value for the attribute.

Magento uses the attribute code internally. While the default value will be automatically applied to products unless specified otherwise.

C. Advanced attribute properties

Advanced Attribute Properties in Magento Admin Panel

You can configure additional settings, such as input validation and unique value requirements. It is an optional setting. You can add search weight, depending on your needs.

It offers more control over how the attribute functions and displays on the front end.

3. Managing labels of Product Attributes

Click on the "Manage Labels" tab. These settings are optional. The label helps identify the attribute in Admin and the storefront of each store view.

Add labels for each store view to display the attribute using different text for different store views. It is useful for multilingual stores or stores with other branding.

Managing Labels of Product Attributes

Configure Storefront properties

It is an optional setting on how an attribute can be used in the storefront and the admin:

It includes options such as:

  • For Search & sorting
  • In layered navigation
  • Price rules
  • Product comparisons.

Configuring Storefront Properties for Attributes

Click on the "Storefront Properties" tab.

Configure the following settings as needed:

1. Use in Layered Navigation Enable this option if you want the attribute to be used as a filter in the layered navigation on category pages.

2. Use in Search Results Layered Navigation Enable this option if you want the attribute to be used as a filter in the layered navigation on search results pages.

3. Visible on Catalog Pages on Storefront Enable this setting if you want the attribute displayed on product listing pages.

4. Used in Product Listing It is used for sorting and filtering products in product listing pages.

5. Used for Sorting in Product Listing Enable this if you use the attribute to be available as a sorting option on product listing pages.

6. Use for Promo Rule Conditions Enable this option if you use the attribute in promotional rule conditions for catalog. Or you can use it for cart price rules.

Once you configure the storefront properties, please click the "Save Attribute" button. It will create a new custom product attribute.

Magento Attribute Sets

Creating and Using Attribute Sets

Attribute sets in Magento are collections of product attributes. These are used to define a group of product characteristics.

Attribute sets help organize and manage attributes more efficiently. It allows you to apply the same attributes to multiple products easily.

Creating and Using Attribute Sets in Magento

  • To create a new attribute set - navigate to "Stores" > "Attributes" > "Attribute Set" in the Magento admin panel.

  • Click on the "Add Attribute Set" button in the top right corner.

  • Enter a unique name for the attribute in the "Name" field.

  • Choose an existing attribute set from the "Based On" dropdown menu to use as a template for the new attribute set.

  • It will copy all the attributes and groups from the selected feature set to the new one.

  • Click the "Save" button to create the new attribute set.

When creating a new product, you can now select the new attribute set from the "Attribute Set" dropdown menu. It will automatically add the product with the attributes from the selected set.

Organizing Attributes in Sets

Proper organization of attributes within attribute sets is crucial. It maintains a clean and efficient product management process.

Organizing Attributes in Sets

Follow these steps to organize attributes in an attribute set:

  • Navigate to "Stores" > "Attributes" > "Attribute Set" in the Magento admin panel.

  • Click on the attribute set you want to edit.

  • On the "Edit Attribute Set" page, you will see the "Groups" section. It contains various attribute groups.

  • You can drag and drop attributes between groups or create new groups by clicking the "Add New" button.

  • To create a new group, enter a name for the group and click the "OK" button.

  • The new group will appear in the "Groups" section.

  • To add attributes to a group, click the "Unassigned Attributes" section. It reveals a list of attributes not currently assigned to any group. Drag and drop the desired attributes into the appropriate group.

  • You can also remove an attribute from a group. Simply drag and drop it back into the "Unassigned Attributes" section.

  • Reorder the attributes within a group by dragging and dropping them to change their position.

  • Click the "Save" button at the top of the page to save your changes.

Working with Product Attributes

How to get attribute values?

To retrieve values of product attributes in Magento 2, you can use the getCustomAttribute() method in your PHP code.

Here's an example of how to do this:

php
Copy code
if (null !== $product->getCustomAttribute('your_custom_attribute')) {
    echo $product->getCustomAttribute('your_custom_attribute')->getValue();
}

Changing the attribute scope

In some cases, you might need to change the scope of an attribute, such as from Global to Website.

You can create an upgrade script with the following code to make changes in the database:

$setup->updateAttribute('catalog_category', 'menutopdescription1', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE);

Applying promotion rules using specific attribute values

Magento 2 allows you to create promotion rules based on product attributes.

This feature can offer discounts to customers who purchase products with specific attributes.

Applying Promotion Rules Using Specific Attribute Values

To create a promotion rule using product attributes, follow these steps:

  • Go to the Magento 2 admin panel. Navigate to 'Marketing' > 'Promotions' > 'Catalog Price Rules' or 'Cart Price Rules'. It depends on the type of promotion you want to create.

  • Click the 'Add New Rule' button to fill in the required information.

  • In the 'Conditions' tab, click the '+' button. Choose 'Product Attribute Combination'.

Product Attribute Combination in Magento Store

  • Click on the new '+' button and select the attribute you want to use as a condition.

  • Set the desired attribute value or values. Configure the remaining settings for your promotion.

  • Save the rule, which is applied to the specified products based on the attribute value.

Best Practices for Creating and Managing Product Attributes

1. Consistent attribute-naming conventions

Using consistent attribute-naming conventions allows efficient product management.

When creating attributes, ensure that names are clear and accurately describe their property. Avoid using abbreviations, jargon, or complex terms.

Consistency in naming conventions will make it easier to manage your product catalog and help customers find the products they are looking for.

2. Considering attributes use

Before creating an attribute, consider its purpose and how it will be used in your store. Check if the attribute is essential for product filtering, sorting, or comparison.

Consider the type of input required and how it will impact the user experience. With planning, you can minimize unnecessary attributes and improve overall store performance.

3. Managing color attribute values

When working with color attributes, maintain consistency in naming and presentation.

Use standardized color names and you can provide a visual swatch for each color. Customers can easily identify and select the desired color when browsing or filtering products.

4. Variations management with configurable products

For products with multiple variations, use Magento’s configurable products.

Configurable products allow you to create a single product with multiple options, such as size or color.

Customers can easily select their preferred options. It reduces the number of individual products you need to manage.

5. Weighted search

In Magento 2, you can assign a search weight to each attribute. It influences the search results order.

Assign higher search weights to attributes that are more important or relevant to your customers.

It improved search results' relevance. You can ensure the most important attributes are displayed prominently.

6. Removing unused properties

Regularly review your product attributes and remove any unnecessary properties. The practice maintains an organized product catalog, reducing clutter. It makes it easier for types of store owners and customers to navigate.

Removing unused attributes also helps to improve overall store performance. It reduces the amount of data that needs to be processed.

Summary

This tutorial covered the importance of product attributes in Magento and how to set them. We discussed the difference between system and custom attributes.

We covered the steps to create product attributes, manage attribute sets, and work with product attributes in various ways. You got the best practices for creating and managing product attributes.

Product attributes can help deliver a personalized shopping experience for your customers. It enhances customer satisfaction and also contributes to your store's overall performance and growth.

Get more information and detailed how-to topics on Magento tutorials.

Nikita S.
Nikita S.
Lead Technical Writer

As a lead technical writer, Nikita S. is experienced in crafting well-researched articles that simplify complex information and promote technical communication. She has expertise in cloud computing and holds a specialization in SEO and digital marketing.


Get the fastest Magento Hosting! Get Started