Anonymous Anonymous - 2 years ago 306
PHP Question

Magento 1.9.1 model rewrite not executed

I've been trying for days now to get a rewritten model to function.
The code seems to be correct and the rewrite seems to work, but I can't see the logs, that I've put there for debugging purposes in the system.log.

I've tried several tutorials with all the same result.

Module WR_EPO is active and running. Even some installer-scripts for adding new columns in to my sql database are working fine.

Here's my code:

under local/WR/EPO/etc/config.xml:

<?xml version="1.0"?>




the rewritten model under local/WR/EPO/Catalog/Model/Product/Option/Type/text.php:


class WR_Catalog_Model_Product_Option_Type_Text extends Mage_Catalog_Model_Product_Option_Type_Text
* Validate user input for option
* @throws Mage_Core_Exception
* @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
* @return Mage_Catalog_Model_Product_Option_Type_Default
public function validateUserValue($values)

$option = $this->getOption();
$value = trim($this->getUserValue());

// Check requires option to have some value
if (strlen($value) == 0 && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) {
Mage::throwException(Mage::helper('catalog')->__('Please specify the product\'s required option(s).'));

// Check maximal length limit
$maxCharacters = $option->getMaxCharacters();
$minValue = $option->getMinValue();
$maxValue = $option->getMaxValue();
if ($maxCharacters > 0 && Mage::helper('core/string')->strlen($value) > $maxCharacters) {
"success maxChar in text.php",

Mage::Log("success maxChar in text.php");
if (isset($minValue) && isset($maxValue) && ($value < $minValue || $value > $maxValue)){
Mage::throwException(Mage::helper('catalog')->__('The value is not in range!!!'));
Mage::throwException(Mage::helper('catalog')->__('The text is too long'));

return $this;


here I add 2 variables $minValue and $maxValue und afterwards I do the logging into system.log and additionally into a custom log file, but none of them appear, when I refresh the page (cache cleared beforehand).

How can I fix/debug this? Why is the rewritten model not loaded instead of the core one? From what I've read custom rewrites override core Models.

Help is very appreciated

Answer Source

You need to change




put file to WR/EPO/Model/Product/Option/Type/Text.php and change it class name from

class WR_Catalog_Model_Product_Option_Type_Text


class WR_EPO_Model_Product_Option_Type_Text
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download