In admin panel I have created a product attribute
as \'merchant
\'. I want to add a new column for merchant
in sales_flat_order_i
First of all, you need to add the new column to sales_flat_quote item, and sales_flat_order_item. the best explanation is here: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources
Your setup resource have to looks something like this:
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn(
$installer->getTable('sales/quote_item'), 'merchant', 'VARCHAR(20) NOT NULL');
$installer->getConnection()
->addColumn(
$installer->getTable('sales/order_item'), 'merchant', 'VARCHAR(20) NOT NULL')
In order to pass the data from the quote_item to order_item you need in to specify in your config.xml something like this: *
And then, in order to save the data in quote item, you need an observer, I suggest you to read this: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method The event you are looking for is In the observer method you'll have to do something like this
class MyNamespace_Mymodule_Model_Observer
{
public function saveTheMerchant($observer)
{
$item = $observer->getEvent()->getQuoteItem();
$product = $item->getProduct();
$item->setMerchant($product->getMethant());
$item->save();
}
}
Greetings.