---
title: "How to Set Product Custom Attribute Set as Default in Magento 2?"
url: "https://magecomp.com/blog/set-product-custom-attribute-set-as-default-magento-2/"
date: "2023-04-14T15:45:13+00:00"
modified: "2025-02-13T08:55:25+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 340
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "To Set Product Custom Attribute Set as Default in Magento 2, you need to create di.xml and AttributeSet.php files. Learn more"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How Resize Image of Specific Products Based on Admin Configuration?"
    url: "https://magecomp.com/blog/magento-2-resize-image-of-specific-products-based-on-admin-configuration/"
  - title: "How to Join Two Tables and Create Admin Grid using UI Component in Magento 2?"
    url: "https://magecomp.com/blog/join-two-tables-and-create-admin-grid-using-ui-component-magento-2/"
  - title: "Top 6 Magento 2 Quantity Dropdown Extension Providers"
    url: "https://magecomp.com/blog/top-magento-2-quantity-dropdown-extension-providers/"
---

# How to Set Product Custom Attribute Set as Default in Magento 2?

_Published: April 14, 2023_  
_Author: Dhiren Vasoya_  

![How to Set Product Custom Attribute Set as Default in Magento 2](https://magecomp.com/blog/wp-content/uploads/2023/04/How-to-Set-Product-Custom-Attribute-Set-as-Default-in-Magento-2-1024x512.webp)

**Hello Magento Friends,**

In today’s blog, I will explain How to Set Product Custom Attribute Set as Default in Magento 2.
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-3.webp)](https://magecomp.com/services/hire-magento-programmer/)

In Default Magento 2, the “Default” option is selected for the attribute set field when you create a new product. Checkout below image
![before attribute set](https://magecomp.com/blog/wp-content/uploads/2023/04/before-attribute-set-1.webp)

If you want to change the default selection and set the “Custom attribute set” as the default selection in the Attribute Set field, you can use the below method. Before that learn
[**How to Create New Attribute Sets in Magento 2**](https://magecomp.com/blog/create-new-attribute-sets-magento-2/)

Let’s get started,
## Steps to Set Product Custom Attribute Set as Default in Magento 2:
**Step 1:** Create **di.xml** at the below path
**app\code\Vendor\Extension\etc\adminhtml**

And add the following code
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="MagentoCatalogUiDataProviderProductFormModifierAttributeSet" type="VendorExtensionUiDataProviderProductFormModifierAttributeSet"></preference>
</config>
```

[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2023/04/Magento-Malware-Removal-CTA-1.webp)](https://magecomp.com/magento-malware-removal.html)

**Step 2:** Create **AttributeSet.php** in the following path
**Vendor\Extension\Ui\DataProvider\Product\Form\Modifier**

And add the code as follows
```
<?php

namespace VendorExtensionUiDataProviderProductFormModifier;

class AttributeSet extends MagentoCatalogUiDataProviderProductFormModifierAttributeSet
{
    public function modifyData(array $data)
    {
	// 4 is default attribute set id in my case
        if($this->locator->getProduct()->getAttributeSetId() ==4){
	// Replace it with your custom attribute set id whatever you want to set
            $attributesetId=10;
        }else{
          //This is for already created product we are getting previously saved value
            $attributesetId=$this->locator->getProduct()->getAttributeSetId();
        }

        return array_replace_recursive(
            $data,
            [
                $this->locator->getProduct()->getId() => [
                    self::DATA_SOURCE_DEFAULT => [
                        'attribute_set_id' => $attributesetId
                    ],
                ]
            ]
        );
    }
}
```

**Result:**

![after attribute set](https://magecomp.com/blog/wp-content/uploads/2023/04/after-attribute-set-1.webp)

## Conclusion:
This way, you can set the product custom attribute set as default in Magento 2. If you are unable to set the custom attribute set as default, let me know through the comment section. Share the solution with your friends and stay in touch with us.
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2023/10/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/set-product-custom-attribute-set-as-default-magento-2/](https://magecomp.com/blog/set-product-custom-attribute-set-as-default-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-20 17:47:04 UTC_  
