WackGet
WackGet

Reputation: 2965

Disabling editing of a product <input> field in Magento's "manage products" area?

In Magento Admin -> Catalog -> Manage Products, I'd like to disable a couple of product fields so that administrators can't edit them.

Essentially turning this: enter image description here

into this: enter image description here

Magento pulls the field HTML in via the template at adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml, via the function getElementHtml() but I can't find the place where the actual <input> HTML is being constructed.

Besides, there's probably a more modular way of doing this, rather than just editing the template's HTML.

Any thoughts?

Upvotes: 2

Views: 4778

Answers (1)

WackGet
WackGet

Reputation: 2965

I discovered a similar question, here, which led me to the solution:

  1. Open up app\design\adminhtml\default\default\template\catalog\form\renderer\fieldset\element.phtml

  2. Find the line which reads <?php $this->checkFieldDisable() ?>

  3. Underneath this, insert this block (edit "sku" to whatever you need):

<?php

// Disable editing of SKU field

if ($_element->name == "sku") {

$_element->setDisabled(true);

}

?>

There may be an even more elegant way of doing this, such as setting the "disabled" option somewhere in the database, but since these are system attributes I doubt it. This works!

Upvotes: 2

Related Questions