Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
  2. $installer->startSetup();
  3.  
  4. $installer->addAttribute('order', 'erp_associated_ids', array(
  5. 'user_defined' => true,
  6. 'type' => 'varchar',
  7. 'backend' => 'mycompany_mymodule/adminhtml_system_config_backend_csv',
  8. 'label' => 'Associated Order IDs',
  9. 'input' => 'text',
  10. 'source' => '',
  11. 'visible' => true,
  12. 'required' => false,
  13. 'default' => '',
  14. 'frontend' => '',
  15. 'unique' => false,
  16. 'note' => 'CSV of order IDs'
  17. ));
  18.  
  19. $installer->endSetup();
  20.  
  21. class Mycompany_Mymodule_Model_Adminhtml_System_Config_Backend_Csv extends Mage_Core_Model_Config_Data {
  22.  
  23. protected function _afterLoad()
  24. {
  25. if (is_string($this->getValue())) {
  26. $value = $this->getValue();
  27. $this->setValue(empty($value) ? false : explode(',', $value));
  28. }
  29. }
  30.  
  31. protected function _beforeSave()
  32. {
  33. if (is_array($this->getValue())) {
  34. $this->setValue(implode(',', $this->getValue()));
  35. }
  36. }
  37. }
  38.  
  39. Mage::getModel('sales/order')
  40. ->load(25)
  41. ->setErpAssociatedIds(array('12345', '98765'))
  42. ->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement