Agregar el atributo personalizado para sales_quote_address
Pregunta
Me gustaría añadir un atributo personalizado de la Sales_Quote_Address
en el modelo de Magento.He buscado en Google durante un par de horas, ahora, y no puedo encontrar una manera de hacerlo.Es posible?O tengo que configurar el atributo en el Sales_Order
sí y lo agarra de allí después?
Gracias
Solución
Así que, aquí está lo que terminé haciendo:
$installer = $this;
$installer->startSetup();
/* @var $addressHelper Mage_Customer_Helper_Address */
$addressHelper = Mage::helper('customer/address');
$store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);
/* @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
// update customer address user defined attributes data
$attributes = array(
'attribute_name' => array(
'label' => 'Attribute label',
'backend_type' => 'int',
'frontend_input' => 'select',
'is_user_defined' => 0,
'is_system' => 0,
'is_visible' => 0,
'sort_order' => 140,
'is_required' => 0,
'multiline_count' => 0
),
);
foreach ($attributes as $attributeCode => $data) {
$attribute = $eavConfig->getAttribute('customer_address', $attributeCode);
$attribute->setWebsite($store->getWebsite());
$attribute->addData($data);
$usedInForms = array(
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address'
);
$attribute->setData('used_in_forms', $usedInForms);
$attribute->save();
}
$installer->run("
ALTER TABLE {$this->getTable('sales_flat_quote_address')} ADD COLUMN `column_name` TINYINT(4) DEFAULT NULL;
ALTER TABLE {$this->getTable('sales_flat_order_address')} ADD COLUMN `column_name` TINYINT(4) DEFAULT NULL;
");
$installer->endSetup();
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange