Getting following error
Error in file: "/www/Abc/app/code/local/Abc/Bar/sql/abc_bar_setup/mysql4-upgrade-1.0.0-1.1.0.php" - Can't retrieve entity config: abc_bar/baz
I have created a custom table by following
/app/code/local/Abc/Bar/sql/abc_bar_setup/mysql4-install-1.0.0.php
<?php
$installer = $this;
$installer->startSetup();
$table = $installer->getConnection()
->newTable($installer->getTable('abc_bar/baz'))
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,
), 'ID')
->addColumn('name', Varien_Db_Ddl_Table::TYPE_CLOB, 0, array(
'nullable' => false,
), 'Name');
$installer->getConnection()->createTable($table);
$installer->endSetup();
I added a custom Grid, and created form like this.
/www/Abc/app/code/local/abc/Bar/Block/Adminhtml/Baz/Grid.php
<?php
class Abc_Bar_Block_Adminhtml_Baz_Grid extends Mage_Adminhtml_Block_Widget_Grid {
public function __construct() {
parent::__construct();
$this->setDefaultSort('id');
$this->setId('abc_bar_baz_grid');
$this->setDefaultDir('asc');
$this->setSaveParametersInSession(true);
}
protected function _getCollectionClass() {
return 'abc_bar/baz_collection';
}
protected function _prepareCollection() {
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns() {
$this->addColumn('id', array(
'header' => $this->__('ID'),
'align' => 'right',
'width' => '50px',
'index' => 'id'
)
);
$this->addColumn('name', array(
'header' => $this->__('Name'),
'index' => 'name'
)
);
return parent::_prepareColumns();
}
public function getRowUrl($row) {
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}
}
And
/www/Abc/app/code/local/Abc/Bar/Block/Adminhtml/Baz/Edit/Form.php
class Abc_Bar_Block_Adminhtml_Baz_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
public function __construct() {
parent::__construct();
$this->setId('abc_bar_baz_form');
$this->setTitle($this->__('Baz Information'));
}
protected function _prepareForm() {
$model = Mage::registry('abc_bar');
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
'method' => 'post'
));
$fieldset = $form->addFieldset('base_fieldset', array(
'legend' => Mage::helper('checkout')->__('Baz Information'),
'class' => 'fieldset-wide',
));
if ($model->getId()) {
$fieldset->addField('id', 'hidden', array(
'name' => 'id',
));
}
$fieldset->addField('name', 'text', array(
'name' => 'name',
'label' => Mage::helper('checkout')->__('Name'),
'title' => Mage::helper('checkout')->__('Name'),
'required' => true,
));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
For this I was following markoshust. By this a table having two fields id and name has been created.And data is being shown into grid. That's fine. But when I try to add a new column, let say 'sales_emails' by following
/app/code/local/Abc/Bar/sql/abc_bar_setup/mysql4-upgrade-1.0.0-1.1.0
<?php
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('abc_bar/baz'),
'emails',
array(
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'comment' => 'Sales Emails for Order type'
)
);
$installer->endSetup();
And I have add in following
/www/Abc/app/code/local/abc/Bar/Block/Adminhtml/Baz/Grid.php
protected function _prepareColumns() {
// Add the columns that should appear in the grid
$this->addColumn('id', array(
'header' => $this->__('ID'),
'align' => 'right',
'width' => '50px',
'index' => 'id'
)
);
$this->addColumn('name', array(
'header' => $this->__('Name'),
'index' => 'name'
)
);
$this->addColumn('emails', array(
'header' => $this->__('Emails'),
'index' => 'emails'
)
);
return parent::_prepareColumns();
}
And in
/www/Abc/app/code/local/Abc/Bar/Block/Adminhtml/Baz/Edit/Form.php
protected function _prepareForm() {
$model = Mage::registry('abc_bar');
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
'method' => 'post'
));
$fieldset = $form->addFieldset('base_fieldset', array(
'legend' => Mage::helper('checkout')->__('Baz Information'),
'class' => 'fieldset-wide',
));
if ($model->getId()) {
$fieldset->addField('id', 'hidden', array(
'name' => 'id',
));
}
$fieldset->addField('name', 'text', array(
'name' => 'name',
'label' => Mage::helper('checkout')->__('Name'),
'title' => Mage::helper('checkout')->__('Name'),
'required' => true,
));
$fieldset->addField('emails', 'text', array(
'name' => 'emails',
'label' => Mage::helper('checkout')->__('Emails'),
'title' => Mage::helper('checkout')->__('Emails'),
'required' => true,
));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
And my config.xml is
/www/Abc/app/code/local/Abc/Bar/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Abc_Bar>
<version>1.1.0</version>
</Abc_Bar>
</modules>
<global>
<helpers>
<abc_bar>
<!-- This is where we define our helper directory -->
<class>Abc_Bar_Helper</class>
</abc_bar>
</helpers>
<blocks>
<abc_bar>
<!-- Set a block definition and lookup directory -->
<class>Abc_Bar_Block</class>
</abc_bar>
</blocks>
<models>
<abc_bar>
<!-- This is where we define our model directory -->
<class>Abc_Bar_Model</class>
<!-- Define a resource to create a custom table -->
<resourceModel>abc_bar_mysql4</resourceModel>
</abc_bar>
<!-- Here's our resource model we'll use to create a database table -->
<abc_bar_mysql4>
<class>Abc_Bar_Model_Mysql4</class>
<entities>
<!-- Let's define our table, we'll call it with the baz name, but the real table is abc_bar_baz -->
<!-- After we define our entity, we can call it with our model by calling abc_bar/baz -->
<baz>
<table>abc_bar_baz</table>
</baz>
</entities>
</abc_bar_mysql4>
</models>
<!-- And finally we define our resource setup script -->
<resources>
<abc_bar_setup>
<setup>
<module>Abc_Bar</module>
</setup>
</abc_bar_setup>
</resources>
</global>
<admin>
<routers>
<adminhtml>
<args>
<!-- This is how we load our Adminhtml controllers -->
<modules>
<Abc_Bar before="Mage_Adminhtml">Abc_Bar_Adminhtml</Abc_Bar>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<abc_bar>
<!--
We again keep a nice naming convention and make our module upgrade proof by placing it in a separate folder
- Since we are in the adminhtml node, this will look for the XML file in the app/design/adminhtml/default/default root folder
-->
<file>abc/bar.xml</file>
</abc_bar>
</updates>
</layout>
</adminhtml>
</config>
I have updated by sq version in config file, I am getting following error, what is missing in above process.
Error in file: "/www/Abc/app/code/local/Abc/Bar/sql/abc_bar_setup/mysql4-upgrade-1.0.0-1.1.0.php" - Can't retrieve entity config: abc_bar/baz
config.xml
file