We've got a number of attributes which are generated by basic Excel formulas and then bulk-loaded into the catalog via imports. The process results in "extra" attributes which are read-only and shouldn't be altered by individuals.
Ideally these values wouldn't be stored in EAV attributes, but would instead be calculated on-the-fly as needed. I've considered (and not ruled out) extending the catalog/product
model to have additional methods for this data, such as:
class My_Extension_Model_Catalog_Product extends Mage_Core_Catalog_Product {
public function getSomeValue() {
if (!$x = $this->getX() || !$y = $this->getY()) {
return null;
}
return ($x * $y);
}
}
The attribute needs to be available to consumers who expect it to behave like any other attribute--they should be able to call Mage::getModel('catalog/product')->load(123)->getSomeValue();
without any extra boilerplate or bootstrapping.
What other options would I have? Would there be events that would let me calculate and set the value when the product is being loaded? Or better could I assign the function when the product is loaded?