/** * Change field eav attribute config before saving the value * * @return TM_FireCheckout_Adminhtml_Model_System_Config_Backend_Address_Form_Status */ protected function _beforeSave() { $value = $this->getValue(); $field = $this->getField(); // if option was not changed - don't need to update the attribute if ($value == Mage::getStoreConfig('firecheckout/address_form_status/' . $field)) { return $this; } if ('street1' === $field) { $field = 'street'; } elseif ('region' === $field) { $field = 'region_id'; /* fix for the previous firecheckout bug. Region should not be required */ /* @var $collection Mage_Customer_Model_Resource_Address_Attribute_Collection */ $collection = Mage::getResourceModel('customer/address_attribute_collection')->setCodeFilter('region'); $attribute = $collection->getFirstItem(); if ($attribute) { $attribute->setValidateRules(null)->setIsRequired(0); $attribute->save(); } /* end of fix */ } /* @var $collection Mage_Customer_Model_Resource_Address_Attribute_Collection */ $collection = Mage::getResourceModel('customer/address_attribute_collection')->setCodeFilter($field); $attribute = $collection->getFirstItem(); if (!$attribute) { return $this; } // $entities = Mage::getResourceModel('customer/setup'); $attributes = array(); $filename = Mage::getBaseDir('app') . "/code/core/Mage/Customer/Model/Resource/Setup.php"; if (is_readable($filename)) { $setup = new Mage_Customer_Model_Resource_Setup('customer_setup'); $entities = $setup->getDefaultEntities(); $attributes = $entities['customer_address']['attributes']; } else { $attributes = 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}'; } switch ($value) { case 'required': $rules = null; if (is_string($attributes)) { $rules = $attributes; } elseif (!empty($attributes[$field]['validate_rules'])) { $rules = $attributes[$field]['validate_rules']; } $attribute->setValidateRules($rules)->setIsRequired(1); if ('region_id' === $field || 'postcode' === $field) { // Magento options should be used $attribute->setValidateRules(null)->setIsRequired(0); } break; case 'optional': case 'hidden': $attribute->setValidateRules(null)->setIsRequired(0); break; } $attribute->save(); return $this; }
* obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * @category Adyen * @package Adyen_Payment * @copyright Copyright (c) 2011 Adyen (http://www.adyen.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * @category Payment Gateway * @package Adyen_Payment * @author Adyen * @property Adyen B.V * @copyright Copyright (c) 2014 Adyen BV (http://www.adyen.com) */ $installer = new Mage_Customer_Model_Resource_Setup('core_setup'); $installer->startSetup(); /** @var Magento_Db_Adapter_Pdo_Mysql $connection */ $connection = $installer->getConnection(); $entityTypeId = $installer->getEntityTypeId('customer'); $attributeCode = 'adyen_customer_ref'; $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId); $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); $installer->addAttribute('customer', $attributeCode, array('input' => 'text', 'type' => 'text', 'label' => 'Adyen Customer Reference', 'note' => 'Optional customer reference ID, only fill when customer reference is not the customer ID (when importing data from older systems for example).', 'visible' => 1, 'required' => 0, 'user_defined' => 0)); $attributeSortOrder = 120; $installer->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, $attributeCode, $attributeSortOrder); $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode); $oAttribute->setData('used_in_forms', array('adminhtml_customer')); $oAttribute->setData('sort_order', $attributeSortOrder); $oAttribute->save(); $connection->addColumn($this->getTable('sales/billing_agreement'), 'agreement_data', array('type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Agreement Data'));
public function getDefaultEntities() { return $this->getAdditionalAttributes(parent::getDefaultEntities()); }