I have a site where we have about 300 attribute sets that we are not using. I want to mass delete this attribute set but I can't find how to do that.

I will prefer an option where I can delete it from the interface.


Try This Code




namespace VendoreName\CustomizeAttributeSet\Controller\Adminhtml\Index;

use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;

class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set implements HttpPostActionInterface

    protected $attributeSetRepository;

    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Eav\Api\AttributeSetRepositoryInterface $attributeSetRepository,
        \Magento\Framework\Registry $coreRegistry
    ) {
        parent::__construct($context, $coreRegistry);
        $this->attributeSetRepository = $attributeSetRepository;

    public function execute()
        $deletedAttributeCount = 0;
        $data = $this->getRequest()->getPostValue();
        $resultRedirect = $this->resultRedirectFactory->create();
        if (isset($data['attribute_list'])) {
            if (count($data['attribute_list'])) {
                foreach ($data['attribute_list'] as $key => $value) {
                    try {
                    } catch (\Exception $e) {
                        $this->messageManager->addErrorMessage(__('We can\'t delete this set right now. ID: ' . $value));
        $this->messageManager->addSuccessMessage(__('The ' . $deletedAttributeCount . ' attribute set has been removed.'));
        return $resultRedirect;

You can download module click here

Note: Every product must belong to a specific attribute set so please check before deleting the attribute set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.