Last active
February 24, 2020 20:48
-
-
Save cagartner/4fbd9d8506f7a520807ea0b51979fc61 to your computer and use it in GitHub Desktop.
Adiciona atributo a um grupo do magento 1 / add custom attribute to a custom attribute_set's group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
/* @var $installer Mage_Catalog_Model_Resource_Setup */ | |
$installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); | |
$installer->startSetup(); | |
$attribute = 'attribute_code'; | |
$groupName = 'General'; // Or other | |
$entityTypeId = $installer->getEntityTypeId('catalog_product'); | |
$attributeSetId = $installer->getAttributeSet($entityTypeId, 'Default', 'attribute_set_id'); // Can be other if yout have custom attribute_set | |
$attributeGroupId = $installer->getAttributeGroupId($entityTypeId, $attributeSetId, $groupName); | |
// Add existing attribute to group | |
$attributeId = $installer->getAttributeId($entityTypeId, $attribute); | |
$installer->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, $attributeId, 35); | |
$installer->endSetup(); | |
} catch (Exception $e) { | |
Mage::logException($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment