Exemple #1
0
 /**
  * Preparing form elements for editing Entity Type
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save'), 'method' => 'post'));
     $entityType = Mage::registry('etm_entity_type');
     $fieldSet = $form->addFieldset('entity_type_data', array('class' => 'fieldset-wide', 'legend' => Mage::helper('goodahead_etm')->__('General')));
     $validateClass = sprintf('required-entry validate-code validate-length maximum-length-%d', Goodahead_Core_Helper_Data::getConstValue('Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH', 50));
     $fieldSet->addField('entity_type_code', 'text', array('label' => Mage::helper('goodahead_etm')->__('Entity Type Code'), 'name' => 'entity_type_code', 'class' => $validateClass, 'required' => true));
     $fieldSet->addField('entity_type_name', 'text', array('label' => Mage::helper('goodahead_etm')->__('Entity Type Name'), 'name' => 'entity_type_name', 'class' => 'required-entry', 'required' => true));
     if ($entityType->getId()) {
         //            $form->addField('entity_type_id', 'hidden', array(
         //                'name' => 'entity_type_id',
         //            ));
         // TODO: Rework
         $entityTypeAttributes = Mage::getModel('goodahead_etm/source_entity_attribute')->toOptionsArrayWithoutExcludedTypes($entityType, true, array('boolean', 'multiselect', 'select', 'image', 'static'));
         $fieldSet->addField('default_attribute_id', 'select', array('label' => Mage::helper('goodahead_etm')->__('Default Attribute'), 'name' => 'default_attribute_id', 'required' => false, 'values' => $entityTypeAttributes, 'note' => Mage::helper('goodahead_etm')->__('This attribute is used to display entity label')), 'entity_type_name');
         $form->getElement('entity_type_code')->setReadonly('readonly');
         $form->getElement('entity_type_code')->setDisabled(1);
         Mage::dispatchEvent('goodahead_etm_entity_types_edit_prepare_form_main_section', array('form' => $form));
         $form->setValues($entityType->getData());
     } else {
         Mage::dispatchEvent('goodahead_etm_entity_types_edit_prepare_form_main_section', array('form' => $form));
     }
     $form->setFieldNameSuffix('data');
     $this->setForm($form);
     return parent::_prepareForm();
 }
Exemple #2
0
 public function isNewDdlModel()
 {
     $coreVersion = Goodahead_Core_Helper_Data::getMagentoCoreVersion();
     return version_compare($coreVersion, '1.6', '>=');
 }
        if (empty($item['source_model'])) {
            $update['source_model'] = $helper->getAttributeSourceModelByInputType($item['frontend_input']);
        }
        if (empty($item['backend_model'])) {
            $update['backend_model'] = $helper->getAttributeBackendModelByInputType($item['frontend_input']);
        }
        if (empty($item['frontend_model'])) {
            $update['frontend_model'] = $helper->getAttributeFrontendModelByInputType($item['frontend_input']);
        }
        $update = array_filter($update);
        if (!empty($update)) {
            $installer->getConnection()->update($installer->getTable('eav/attribute'), $update, $installer->getConnection()->quoteInto('attribute_id = ?', $item['attribute_id']));
        }
    }
}
$installer->getConnection()->dropColumn($installer->getTable('goodahead_etm/eav_attribute'), 'attribute_name');
$installer->getConnection()->addColumn($installer->getTable('goodahead_etm/eav_attribute'), 'sort_order', 'INT(4) UNSIGNED NOT NULL DEFAULT 0');
$select = $installer->getConnection()->select();
$select->from(array('main_table' => $installer->getTable('eav/entity_type')), array('entity_type_id', 'entity_type_code'));
$select->joinInner(array('g' => $installer->getTable('goodahead_etm/eav_entity_type')), 'main_table.entity_type_id = g.entity_type_id', array());
$items = $installer->getConnection()->fetchAll($select);
if ($items && is_array($items)) {
    foreach ($items as $item) {
        $installer->getConnection()->update($installer->getTable('eav/entity_type'), array('entity_model' => sprintf('goodahead_etm/custom_%s_entity', $item['entity_type_code']), 'attribute_model' => 'goodahead_etm/entity_attribute', 'entity_table' => 'goodahead_etm/entity', 'additional_attribute_table' => 'goodahead_etm/eav_attribute', 'entity_attribute_collection' => 'goodahead_etm/entity_attribute_collection'), $installer->getConnection()->quoteInto('entity_type_id = ?', $item['entity_type_id']));
    }
}
$tableTypes = array('int', 'varchar', 'char', 'text', 'decimal', 'datetime');
foreach ($tableTypes as $type) {
    $installer->getConnection()->addKey($installer->getTable('goodahead_etm/entity') . '_' . $type, $installer->getIdxName($installer->getTable('goodahead_etm/entity') . '_' . $type, array('entity_type_id', 'attribute_id', 'store_id', 'entity_id')), array('entity_type_id', 'attribute_id', 'store_id', 'entity_id'), Goodahead_Core_Helper_Data::getConstValue('Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE', Goodahead_Core_Model_Resource_Setup_Compatibility::INDEX_TYPE_UNIQUE));
}
$installer->endSetup();