title: Magento - Quote/order product item attribute based on user input
body: <p><strong>Summary</strong></p>
  
  <p>I want to create a product attribute that is not saved to products, or displayed on the product edit page like ordinary product attributes. Instead I want it to be saved to order/quote items and displayed on orders, invoices and such. It should also be configurable by the customer in the frontend before adding a product to the cart.</p>
  
  <p><strong>Details</strong></p>
  
  <ul>
  <li>Just like with <em>Custom Options</em>, a form element should be added to the frontend product page.
  <ul>
  <li><strong>Unlike</strong> Custom Options, this is not an <em>actual</em> product attribute. It should not be displayed on the admin product pages or attribute sets.</li>
  <li>The customer is required to provide a valid value. I need to be able to do server-side validation.</li>
  <li>I want to have a .phtml template generating its html. Currently I'm able to override <em>app/design/frontend/base/default/catalog/product/view/type/default.phtml</em> with satisfactory (design) results. However I don't know how to capture, validate and eventually save its value.</li>
  </ul></li>
  <li>The value of this form element should be saved with the quote/order product item.
  <ul>
  <li>This value should be displayed on any and all invoices, orders, sales emails.</li>
  <li>I want to control output with a template, or at least be able to return the string that is used to display the value</li>
  </ul></li>
  </ul>
  
  <p><strong>My questions</strong></p>
  
  <ol>
  <li>How do I validate and eventually save the value from a <code>&lt;input&gt;</code> on the frontend product page to the quote item when the product is added to the cart, and later in the checkout process to the order item?</li>
  <li>How do I display this value on the order, invoice, sales emails and such pages?</li>
  <li>How do I filter an order collection to fetch orders that has items with my value set to a specific value?</li>
  </ol>
  
  <p><strong>Update 1</strong></p>
  
  <p>I've discovered that I can run this code on a <code>catalog/product</code> model (and probably <code>sales/quote_item</code> as well) during events such as <code>sales_quote_item_qty_set_after</code></p>
  
  <pre><code>$infoBuyRequest = $product-&gt;getCustomOption('info_buyRequest');
  $buyRequest = new Varien_Object(unserialize($infoBuyRequest-&gt;getValue()));
  $myData = $buyRequest-&gt;getMyData();
  </code></pre>
  
  <p>In this way I was able to retrieve my custom, customer supplied, data from my <code>&lt;input&gt;</code> on the product page.</p>
  
  <p>I suspect this <code>info_buyRequest</code> is saved with the quote and order items. If so, this <em>partially</em> solved my problems 1 and 2. However, I still dont know where it's suitable to run this code, and I dont know how to display it on the backend order/quote/report pages. Also I belive since this is stored as a serialized value in the database, it will be most difficult to get quote/order item collections based on my custom data.</p>