We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    If you need to assign your custom attribute in all attribute set programmatically then you can used below steps:

    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
     
    $attributeCode = 'is_featured';
    $attributeGroup = 'General';
     
    $eavSetup = $objectManager->create(MagentoEavSetupEavSetup::class);
    $config = $objectManager->get(MagentoCatalogModelConfig::class);
    $attributeManagement = $objectManager->get(MagentoEavApiAttributeManagementInterface::class);
     
    $entityTypeId = $eavSetup->getEntityTypeId(MagentoCatalogModelProduct::ENTITY);
    $attributeSetIds = $eavSetup->getAllAttributeSetIds($entityTypeId);
    foreach ($attributeSetIds as $attributeSetId) {
     if ($attributeSetId) {
     $group_id = $config->getAttributeGroupId($attributeSetId, $attributeGroup);
     if(empty($group_id)){ continue; }
     $attributeManagement->assign(
     'catalog_product',
     $attributeSetId,
     $group_id,
     $attributeCode,
     100
     );
     }
    }

    Here, we performed the task using objectManager. But You can perform it via module.

    field_5bfb909c5ccae

      Get a Free Quote