Question

I found a question about locking product attributes so that they cannot be edited after the product is created. I'd like to do the same thing with a customer attribute in CE.

The solution with products is to use lockAttribute() inside the model's _load_after event, but lockAttribute() doesn't exist on the customer model.

Invalid method Mage_Customer_Model_Customer::lockAttribute(Array
(
    [0] => my_custom_attribute
)
)

Is there a simple way to lock a customer attribute by calling a different method somewhere, or do I need to do something like override the relevant adminhtml form model and template and lock the field by hand?

Était-ce utile?

La solution

So in principle what you can do is using the customer's save before event.

  1. Check if the object is new as on first save you want to be able to set the value,
  2. If this is not the first save then reset the data for some set attributes using the function getOrigData,

I have done a quick search of the code and I do not think there is an inbuilt function for locking customer attribute.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top