SHARE
TWEET

Untitled

a guest Jul 16th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5.  
  6. $ATTRIBUTE_CODE = 'attribute_code';
  7. $ATTRIBUTE_GROUP = 'attribute_group';  //General
  8.  
  9. use MagentoFrameworkAppBootstrap;
  10. require __DIR__ . '/app/bootstrap.php';
  11.  
  12. $bootstrap = Bootstrap::create(BP, $_SERVER);
  13.  
  14. $objectManager = $bootstrap->getObjectManager();
  15. $state = $objectManager->get(MagentoFrameworkAppState::class);
  16. $state->setAreaCode('adminhtml');
  17.  
  18. /* Attribute assign logic */
  19. $eavSetup = $objectManager->create(MagentoEavSetupEavSetup::class);
  20. $config = $objectManager->get(MagentoCatalogModelConfig::class);
  21. $attributeManagement = $objectManager->get(MagentoEavApiAttributeManagementInterface::class);
  22.  
  23. $entityTypeId = $eavSetup->getEntityTypeId(MagentoCatalogModelProduct::ENTITY);
  24. $attributeSetIds = $eavSetup->getAllAttributeSetIds($entityTypeId);
  25. foreach ($attributeSetIds as $attributeSetId) {
  26.     if ($attributeSetId) {
  27.         $group_id = $config->getAttributeGroupId($attributeSetId, $ATTRIBUTE_GROUP);
  28.         $attributeManagement->assign(
  29.             'catalog_product',
  30.             $attributeSetId,
  31.             $group_id,
  32.             $ATTRIBUTE_CODE,
  33.             999
  34.        );
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top