The list of attributes that define the characteristics of a product is called attribute sets. Any information that makes the product unique can be displayed using product attributes.
While working with attributes, you may also need to get product options in Magento 2 programmatically.
For a store with thousands of products, it can be tiresome to handle its information like attributes, attribute sets, etc. And, a store owner often needs to get the details of the attribute set in order to update the product or for displaying it categorically in the frontend based on its properties.
Be it for updating the products or improving the in-store experience, it is often the admin’s requirement to get product attribute set name in Magento 2 and the post shows the programmatic solution for the same.
Steps to Get Product Attribute Set Name in Magento 2:
use Magento\Catalog\Model\Product;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
protected $product;
protected $attributeSetRepository;
public function __construct(
Product $product,
AttributeSetRepositoryInterface $attributeSetRepository)
{
$this->product = $product;
$this->attributeSetRepository = $attributeSetRepository;
}
public function getAttributeSetName($productId)
{
$product = $this->product->load($productId);
$attributeSet = $this->attributeSetRepository->get($product->getAttributeSetId());
return $attributeSet->getAttributeSetName();
}
The above code will print the names of the attribute set related to the product.

That’s it.
Feel free to share the solution with Magento community via social media.
Thank You.