Design Guide - Sales Order

Showing Vehicles On the Sales Order

If you want to view the user's vehicle on the sales orders, we must add an EAV attribute for storing the customer's vehicle fit for each order that comes thru. Run the following SQL ( phpmyadmin is one possible method to run it. )

If all your tables begin with a prefix, for instance prefix_eav_attribute instead of eav_attribute, please edit the parts in bold ( eav_attribute and sales_order might be changed to, for instance: prefix_eav_attribute & prefix_sales_order ).

Magento 1.4.1.x

ALTER TABLE `sales_flat_order` ADD `elite_fit` INT( 25 ) NOT NULL ;
Note: This may not be neccessary depending on installation method, starting with Magento 1.4.1.x.

Magento 1.4.0.x
Magento 1.4.x

            INSERT INTO `eav_attribute` (
`attribute_id` ,
`entity_type_id` ,
`attribute_code` ,
`attribute_model` ,
`backend_model` ,
`backend_type` ,
`backend_table` ,
`frontend_model` ,
`frontend_input` ,
`frontend_label` ,
`frontend_class` ,
`source_model` ,
`is_required` ,
`is_user_defined` ,
`default_value` ,
`is_unique` ,
`note`
)
VALUES (
NULL , '11', 'elite_fit', NULL , NULL , 'static', NULL , NULL , NULL , NULL , NULL , NULL , '0', '0', NULL , '0', ''
);

ALTER TABLE `sales_order` ADD `elite_fit` INT( 25 ) NOT NULL ;

Insert snippet to display the customer's fit on the order page. Open app/design/adminhtml/default/default/template/sales/order/view/info.phtml. We recommend placing this below the customer group data. The customer group section looks like this:
    <tr>
        <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Group') ?></label></td>
        <td><strong><?php echo $_groupName ?></strong></td>
    </tr>
    
Immediately following that we recommend inserting the following snippet:
     <tr>
        <td class="label"><label>Vehicle Fit</label></td>
        <td>
        <?php
        if( (int)$_order->getEliteFit() )
        {
            try
            {
             $vehicleFinder = new Elite_Vaf_Model_Vehicle_Finder( new Elite_Vaf_Model_Schema );
             $fit = $vehicleFinder->findByLeaf( (int)$_order->getEliteFit() );
             echo htmlentities( $fit );
            }
            catch( Exception $e )
            {
             echo 'Unable to access vehicle information. Exception occured: ' . $e->getTraceAsString();
            }
        }
        ?>
        </td>
    </tr>