I looked for a way to add a custom order item.
Code -> Core -> Mage -> Sales -> Model -> Quote.php
See:
public function addItem(Mage_Sales_Model_Quote_Item $item) {
// Added:
$item->setTrainingLocation($_REQUEST[‘training_location’]);
//Before:
$item->setQuote($this);
}
Now for the above method I have to do changes in Magento core code. How can I do it via an observer or module.
This is what I have tried:
<sales_quote_add_item>
<observers>
<addextraid>
<type>singleton</type>
<class>Mour_Customgroup_Model_Observer</class>
<method>addextraparameter</method>
</addextraid>
</observers>
</sales_quote_add_item>
And observer.php
:
public function addextraparameter($observer) {
$item = $observer->getEvent()->getQuoteItem();
$item->setCustomId(Mage::app()->getRequest()->getParam('custom_id'));
}
Best Answer
You can use the event
sales_quote_add_item
. This is dispatched after$item->setQuote($this);
but this should not be a problem unless you rewritten thesetQuote
method and use the value of training location in that one. I doubt you did this.Here is a tutorial on how to create an observer.
Your method in the observer could look like this: