Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- $ATTRIBUTE_CODE = 'attribute_code';
- $ATTRIBUTE_GROUP = 'attribute_group'; //General
- use MagentoFrameworkAppBootstrap;
- require __DIR__ . '/app/bootstrap.php';
- $bootstrap = Bootstrap::create(BP, $_SERVER);
- $objectManager = $bootstrap->getObjectManager();
- $state = $objectManager->get(MagentoFrameworkAppState::class);
- $state->setAreaCode('adminhtml');
- /* Attribute assign logic */
- $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, $ATTRIBUTE_GROUP);
- $attributeManagement->assign(
- 'catalog_product',
- $attributeSetId,
- $group_id,
- $ATTRIBUTE_CODE,
- 999
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement