I have created a new attribute for Customer Groups called course_id
but I need to get the value of this attribute to then become the value for a new attribute for a Sales Order.
Any ideas how I could do this?
I would assume:
- Create new Sales Order attribute for Course ID
- Get value of Customer Group Course ID to set the value for all new Sales Orders attribute for Course ID
Any help is much appreciated.
EDIT:
This is my current observer, but it doesn't seem to be working correctly. I have added the new new columns in the database (customer group is course_id
and sales order is salescourse_id
):
<?php
class MyCompany_CustomerGroupCourseID_Model_Observer
{
/**
*
* @param Varien_Event_Observer $observer
* @return object
*/
public function setCourseID(Varien_Event_Observer $observer)
{
//get event data
$event = $observer->getEvent();
//get order
$order = $event->getOrder();
//get current customer group and set course id
$customerid = Mage::getSingleton('customer/session')->getCustomerGroupId();
$courseId = Mage::getSingleton('customer/group')->load($customerid)->getData('course_id');
if (isset($courseId)){
$order->setSalescourseId($courseId)
return $this;
}
}
}