Created
February 10, 2021 14:53
-
-
Save Luxato/8658667bfd193afa3ec1cf455d19e952 to your computer and use it in GitHub Desktop.
Magento 1 - How to add attribute to the attribute set
This file contains 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 | |
require_once 'app/Mage.php'; | |
Mage::app(); | |
$attributeSetName = 'Electric scooters'; // Name of the attribute set | |
//$groupName = 'Frontend'; | |
$code = 'my_attribute_code'; | |
try { | |
$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); | |
$attributeSetId = $setup->getAttributeSetId('catalog_product', $attributeSetName); | |
$attributeGroupId = $setup->getAttributeGroupId('catalog_product', $attributeSetId, null); | |
$attributeId = $setup->getAttributeId('catalog_product', $code); | |
$setup->addAttributeToSet($entityTypeId = 'catalog_product', $attributeSetId, $attributeGroupId, $attributeId); | |
echo 'Added Attribute to SET ' . $attributeSetName . ' (' . $code . ')'; | |
} catch (Exception $e) { | |
echo 'ERROR when added Attribute to SET ' . $attributeSetName . ' (' . $code . ')'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment