doukanzhuo4297 2013-01-29 12:13
浏览 44

调用未定义的方法Mage_Customer_Helper_Address :: getAttributeValidationClass()

I have a Magento installation and getting following error on check out page.

Call to undefined method Mage_Customer_Helper_Address::getAttributeValidationClass()

I have checked Mage_Customer_Helper_Address class for this particular function and also searched in class doc. But I did not see this method in doc too. Can anyone tell me what could be the issue ?

Is it a built in method in Magento ? I'm new to Magento and the version installed on server is 1.4.2.0 .

  • 写回答

1条回答 默认 最新

  • dpfln86244 2013-01-29 12:23
    关注

    Could it be that there is some extension incompatible with the version 1.4.2.0? Because Magento v. 1.7, for instance, does have this method in the Mage_Customer_Helper_Address class. You could create an override helper and add this method to it:

    /**
         * Get string with frontend validation classes for attribute
         *
         * @param string $attributeCode
         * @return string
         */
        public function getAttributeValidationClass($attributeCode)
        {
            /** @var $attribute Mage_Customer_Model_Attribute */
            $attribute = isset($this->_attributes[$attributeCode]) ? $this->_attributes[$attributeCode]
                : Mage::getSingleton('eav/config')->getAttribute('customer_address', $attributeCode);
            $class = $attribute ? $attribute->getFrontend()->getClass() : '';
    
            if (in_array($attributeCode, array('firstname', 'middlename', 'lastname', 'prefix', 'suffix', 'taxvat'))) {
                if ($class && !$attribute->getIsVisible()) {
                    $class = ''; // address attribute is not visible thus its validation rules are not applied
                }
    
                /** @var $customerAttribute Mage_Customer_Model_Attribute */
                $customerAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
                $class .= $customerAttribute && $customerAttribute->getIsVisible()
                    ? $customerAttribute->getFrontend()->getClass() : '';
                $class = implode(' ', array_unique(array_filter(explode(' ', $class))));
            }
    
            return $class;
        }
    
    评论

报告相同问题?