/** * add new column, additional attributes and joins are stored on the configuration singleton to add them at the event observer * * @param Varien_Object $params */ protected function _addAction($params) { $columnConfig = array(); $blockId = $params->getBlock()->getId(); /** * @var Hackathon_GridControl_Model_Config $config */ $config = Mage::getSingleton('hackathon_gridcontrol/config'); foreach ($params->getAction()->children() as $attribute) { // 4 special cases if ($attribute->getName() == 'index') { $config->addCollectionUpdate(Hackathon_GridControl_Model_Config::TYPE_ADD_ATTRIBUTE, $blockId, (string) $attribute); } else { if ($attribute->getName() == 'joinAttribute') { $config->addCollectionUpdate(Hackathon_GridControl_Model_Config::TYPE_JOIN_ATTRIBUTE, $blockId, (string) $attribute); continue; } else { if ($attribute->getName() == 'joinField') { $config->addCollectionUpdate(Hackathon_GridControl_Model_Config::TYPE_JOIN_FIELD, $blockId, (string) $attribute); continue; } else { if ($attribute->getName() == 'join') { $config->addCollectionUpdate(Hackathon_GridControl_Model_Config::TYPE_JOIN, $blockId, array('table' => (string) $attribute['table'], 'condition' => (string) $attribute['condition'], 'field' => (string) $attribute['field'], 'array_cols' => array((string) $attribute['field']), 'column' => $params->getColumn()->getName())); continue; } else { if ($attribute->getName() == 'options') { if (strpos((string) $attribute, '::') !== false) { list($_module, $_method) = explode('::', (string) $attribute); $_module = Mage::getSingleton($_module); $_call = array($_module, $_method); if (is_callable($_call)) { $columnConfig['options'] = call_user_func($_call); continue; } } } } } } } if (count($attribute->children())) { // in case of arrays as attribute values $optionArray = array(); foreach ($attribute->children() as $option) { $optionArray[(string) $option->key] = (string) $option->value; } $columnConfig[$attribute->getName()] = $optionArray; } else { // standard string attribute $columnConfig[$attribute->getName()] = (string) $attribute; } } // add column to grid block $params->getBlock()->addColumn($params->getColumn()->getName(), $columnConfig); }