0

I've built an extension, which is all working correctly on my local / development Magento website, unfortunately after packaging it up and installing on another Magento store, the new attributes I've added to the Admin User don't seem to be saving to the Database.

Here is the code, not sure if I've missed something out of the extension package or what but everything seems to be there so it's confusing me now!

From my extensions config.XML

<blocks>
    <adminhtml>
        <rewrite>
            <permissions_user_edit_tab_main>Liquid11_Veridial_Block_Adminhtml_Permissions_User_Edit_Tab_Main</permissions_user_edit_tab_main>
            <permissions_user_grid>Liquid11_Veridial_Block_Adminhtml_Permissions_User_Grid</permissions_user_grid>
        </rewrite>
    </adminhtml>
</blocks>

Here is what is in Liquid11_Veridial_Block_Adminhtml_Permissions_User_Edit_Tab_Main

/**
 * Add additional Mobile number to Admin user record for Veridial's use
 */
$fieldset->addField('veridial_mobile', 'text', array(
    'name'  => 'veridial_mobile',
    'label' => Mage::helper('adminhtml')->__('Mobile Number'),
    'id'    => 'veridial_mobile',
    'title' => Mage::helper('adminhtml')->__('Mobile Number'),
    'class' => 'required-entry input-text',
    'required' => true,
));

/**
 * Add additional Landline number to Admin user record for Veridial's use
 */
$fieldset->addField('veridial_landline', 'text', array(
    'name'  => 'veridial_landline',
    'label' => Mage::helper('adminhtml')->__('Telephone Number'),
    'id'    => 'veridial_landline',
    'title' => Mage::helper('adminhtml')->__('Telephone Number'),
    'class' => 'input-text',
));

And finally my MySQL code to add the columns to the database (2 separate files)

$installer = $this;
$installer->startSetup();

$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'veridial_landline', array(
    'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
    'length' => 256,
    'nullable' => true,
    'default' => null,
    'comment' => 'Telephone Number'
));

$installer->endSetup();

and

$installer = $this;
$installer->startSetup();

$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'veridial_mobile', array(
    'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
    'length' => 256,
    'nullable' => true,
    'default' => null,
    'comment' => 'Mobile Number'
));

$installer->endSetup();

So, the issue is - The above all seems to work. Admin/user/edit tab is correct (It's got my additional fields) and the Database columns have been added. If I add the data into the Database table itself then it's picked up in the Admin area. For some reason saving the admin/user/edit form just doesn't save the data in veridial_mobile and veridial_landline.

Cache etc has all been refreshed after installing the extension.

  • 1
    The code looks ok at a first glance. Usually these problems happen when you don't clear the cache because the tables schemas are cached even if the cache is off and the new fields are not recognized. But if you say the cache was cleared this should not happen. Maybe you cleared the cache from the wrong place. sometimes Magento writes the cache in the /tmp folder of the system if it cannot write in var/cache. I have no other ideas. – Marius Aug 21 '15 at 11:44
  • Used the cache refresh option in the admin. I'll try removing the files in /var and see if it makes a difference. – Christopher Thrower Aug 21 '15 at 11:47
  • Deleting /var/cache done the trick... Didn't even think of doing that - I'd just used the Admin tools! Thanks :) – Christopher Thrower Aug 21 '15 at 12:09
1

The solution was to ensure the cache was cleared completely by removing the contents within /var/cache - Rather than relying on the Magento cache controls in the admin area.

Perhaps due to the table schemas being cached as per Marius' comment.

  • Same here. All caches were disabled but value was still not saving. rm -rf var/cache/* solved the problem – turson Oct 3 '16 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.