How can I change the label associated with an attribute in the catalog_entity_attribute_save_before event?
When I say label, I mean the value set here:
Catalog -> Attributes -> Manage Attributes -> Click on an attribute -> Manage Labels / Options -> Manage Titles -> Admin
I have tried this in my observer, but $attribute->getLabel()
returns NULL.
class NS1_ProductAttributeSpacesAndProperty_Model_Observer
{
public function catalog_entity_attribute_save_before($observer)
{
$attribute = $observer->getEvent()->getAttribute();
$entityTypeId = $attribute->getEntityTypeId();
if($entityTypeId == 4)
{
// the attribute is a product attribute
$label = $attribute->getLabel();
echo gettype($label);exit; // prints NULL
//$attribute->setLabel("Test");
}
}
}
Edit:
I have managed to retrieve the label with $attribute->getFrontendLabel()
, but I am still unable to update the attribute label before it saves.