Skip to content

Instantly share code, notes, and snippets.

@cagartner
Last active February 24, 2020 20:48
Show Gist options
  • Save cagartner/4fbd9d8506f7a520807ea0b51979fc61 to your computer and use it in GitHub Desktop.
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
<?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