0

My employer uses custom options on an order to store some date that is pulled from a SugarCRM module.

For example, there is a custom option on an order which holds all the colors, one for a size, and a couple other options.

I have built a Printable work order/report outside of Magento...it uses Magento but is not an Extension.

I now need to add the ability to add in these custom options for the old orders in the system.

So I just need to learn how to add a custom option to an old order? Any help would be appreciated, I haven't been able to find much so far and I am pretty new to magento.


UPDATED DETAILS

To clarify more, below is an image from the Magento Admin panel for an actual order that is placed.

In the left column you will see the Custom Order Options please note these are not Product Options but specific to an actual Order only!

I will list the Custom Order Options available for this order...

Custom Neon Products SKU

Custom Image

Custom Size

Flashing

Price

Total Price

Sign Size

Sign Type

Outdoor

Please also note that there are actually more Custom Order Options available but only the options that have a value set for this order show up and are added to the actual database table for this order. Some other options that are available but are not set on this particular order are...

Description

Colors

Backing Type

The order image...

enter image description here

1 Answer 1

1

If I understand correctly, you are looking to add multiple fields to an order (describing the order) The answer I am providing is should work unless you have a lot of options–in which case it may be better to create a separate table and store those options in that table. In addition, what you are describing sounds more like custom options for ordered products and not necessarily custom options for the order.

Create your SQL install script:

<?php 
/** @var Mage_Eav_Model_Entity_Setup $installer */
$installer = Mage::getResourceModel('sales/setup','sales_setup'); // Thanks, @benmarks
$installer->startSetup();

$installer->addAttribute('order', 'size', array('type' => 'text', 'grid' => true, 'input' => 'text'));
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'size', 'text');

$installer->endSetup();

It is important to note that you need to create both the attribute and the column in the table. If you don't, Magento will not save the values to the table.

When you are ready to set the new value, just load up the model:

/** @var Mage_Sales_Model_Order $order **/
$order = Mage::getModel('sales/order')->load($orderId);
$order->setSize($value);

You will also probably need to display the values on the order page. The simplest is to create a block that inserts JS onto the page. Output your HTML to this block and use JS to insert it wherever you want it on the order page.

I can provide more details should you find that helpful.

2
  • 1
    $installer = Mage::getResourceModel('sales/setup','sales_setup'); will get you the most ideal setup class in case your module does not use that sales module's setup class.
    – benmarks
    Jan 7, 2014 at 20:12
  • Thanks for the answer. I have updated my question with more detals as I beleive we are not talking about the same thing. WHat I need to add is called a Custom Order Option as far as I know and is not an attribute nor a product option. Hopefully my updated post will shed more light on to what data I have and where it is at to make it make more sense.
    – JasonDavis
    Jan 8, 2014 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.