¿Cómo agregar un campo personalizado para ordenar en Magento?

I want to add one new custom field to one page checkout in Magento. I have created a module with installer:

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->addAttribute('order', 'deliverydate', array(
    'position'      => 1,
    'input'         => 'text',
    'type'          => 'varchar',
    'label'         => 'Choose delivery date',
    'visible'       => 1,
    'required'      => 0,
    'user_defined' => 1,
    'global'        => 1,
    'visible_on_front'  => 1,


I can see with phpmyadmin that the field has been added to mage_eav_attribute table. I have also added this to shipping-method.phtml :

<div class="form-list field">
   <label for="deliverydate"><?php echo $this->__('Choose delivery date') ?></label>
       <div class="input-box">
      <input type="text" name="deliverydate" id="deliverydate" title="<?php echo $this->__('deliverydate') ?>" class="input-text" />

When I place an order, the custom field won't save. How to make it work? I have added some custom fields to customer with this way and they are working fine. I can also see my custom customer fields automatically on admin/customer but can't see my custom order field in admin/sales_order. Thank you

* Editar:

Esto es lo que he hecho:

I added observer.php to companyname/module/model/observer.php

class Company_Module_Model_Observer
    public function Deliverydate($observer){
        //get event data
        $event = $observer->getEvent();

                //get order
        $order = $event->getOrder();

        //set the country here
        //echo "observer";

And here's my config.xml:

<?xml version="1.0"?>



I think there's some problem with my observer. I think it's not firing.

* Editar:

My observer is working now. The filename must be Observer.php, not observer.php.

preguntado el 31 de julio de 12 a las 10:07

could you share the full code.for me .I have to add in order review tab.. -

1 Respuestas

Agrega un observador:


Y en el mymodule/savefield/model/obsever.php archivo agregue esto:

class Mymodule_Savefield_Model_Observer
    public function Savefield($observer){
        //get event data
        $event = $observer->getEvent();

        //get order
        $order = $event->getOrder();

        //set the variable here

respondido 25 nov., 15:19

I added more info to my question. - Joonas

It's working now and your answer showed me the right direction. Thanks! - Joonas

Donde lo hizo $fieldVal ¿viene de? - PBwebD

How do you make it appear in admin afterwards also on the order? - OZZIE

Every time we need to verify the order after placed by customer. Our sales represent very same order again and again. so that is possible can I add the custom field to the sales order like verify. How can i do it? - Joya

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.