I am edding and filling some attributes programmatically with addAttribute in magento 1.9.3

I don't want them to be editable, so I set "input" => "label", but when I do it I can't select the attributes for the product grid to show on backend ("Manage Products" -> "Grid Attribute Columns" -> "Attribute Columns"). For those for which I set "input" => "text" I can see them in the selection.

How can I make the non-editable custom-attributes visible on the backend product grid? Has anyone dealt with this (input=label)? Should I modify the backend code?

This question is different from Read-Only Product Backend attribute because in my case the attributes are visible in the products tab and everything seems fine from the first glance. Later on it looks like some inconvenience. So I would not just address it to the question about not-working readonly attributes.


1 Answer 1


According to the Magento docs (http://devdocs.magento.com/guides/m1x/api/soap/catalog/catalogProductAttribute/product_attribute.types.html), the following default types are acceptable for product attributes:

  1. text
  2. List item
  3. textarea
  4. date
  5. boolean [yes/no]
  6. multiselect
  7. select
  8. price
  9. media_image

Setting the input type to label will not work, but it sounds like you can lock an attribute by setting it as Read Only after you create it.

public function lockAttributes($observer) {
    $event = $observer->getEvent();
    $product = $event->getProduct();

Credit to this post: Magento read-only and hidden product attributes


Since the catalog_product_load_after event is dispatched for every product load, the attributes supplied in the lock_attributes method are locked after every product load. This could have unexpected results: it is not possible to change the value of the attributes in the lock_attributes method without explicitly unlocking them.

Instead of using the catalog_product_load_after event, it suffices to add an observer for the catalog_product_edit_action event: this event is dispatched only when editing a product in the admin interface.

Not the answer you're looking for? Browse other questions tagged or ask your own question.