0

This question already has an answer here:

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.

marked as duplicate by sv3n, Manoj Deswal, Jai, liyakat, Prince Patel Oct 17 '17 at 4:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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();
    $product->lockAttribute('attribute_code');
}

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

Note:

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.