I need a function or some code to remove an attribute from a set where it is assigned to. I know the function, to assign an attribute:
$setup->addAttributeToSet($entityTypeId, $setId, $groupId, $attributeId, $sortOrder=null)
or to remove an Attribute:
$setup->removeAttribute($entityTypeId, $code)
but the attribute should not be deleted. It must no longer be possible to see the attribute in the AttributeSet 'Default' (group 'General').
I don't find any function like:
removeAttributeFromAttributeSet()
or sth. like that
You could try this code inside your setup script
<?php
/** @var $this Mage_Eav_Model_Entity_Setup */
$this->startSetup();
$this->deleteTableRow(
'eav/entity_attribute',
'attribute_id',
$this->getAttributeId('catalog_product', 'attribute_code_here'),
'attribute_set_id',
$this->getAttributeSetId('catalog_product', 'Default')
);
$this->endSetup();
Below will remove attribute from attributeset
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('catalog_product');
$attributeId = $setup->getAttributeId('catalog_product', 'feature'); //feature is attribute code
$attributeSetId = $setup->getAttributeSetId($entityTypeId, 'Default');
$installer->deleteTableRow('eav/entity_attribute', 'attribute_id', $attributeId, 'attribute_set_id', $attributeSetId);
$installer->endSetup();
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With