I've been struggling with this for a while - I'm new to Magento and haven't programmed in PHP for a while, so please, bear with me.
Doing some changes on a Shipping module to magento I've come to need to save and query an specific extra attribute, which I've managed to add through a simple update script:
<?php
$installer->startSetup();
$table = new Varien_Db_Ddl_Table(); $table->setName('shipping_token');
$table
->addColumn('token_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
array(
'unsigned' => true,
'nullable' => false,
'primary' => true,
'identity' => true,
), 'Entity Id')
->addColumn('rate_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
array(
'unsigned' => true,
'nullable' => false,
), 'Quote Id')
->addColumn('token', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255,
array(
'unique' => true,
), 'Quote Token')
->addIndex(
'ID_QUOTE_TOKEN',
'token_id')
->addForeignKey(
'FK_TOKEN',
'rate_id',
'sales_flat_quote_shipping_rate',
'rate_id',
Varien_Db_Ddl_Table::ACTION_CASCADE,
Varien_Db_Ddl_Table::ACTION_CASCADE);
$installer->getConnection()->createTable($table);
$installer->endSetup();
After that, with some ups and downs, I've been following this tutorial trying to access the models with:
$shipping = Mage::getModel('shipping/token');
$shipping->setToken("whatevercomes");
or
$shipping = Mage::getModel('shipping/token');
$shipping->setData('token', 'whatevercomes');
but since I'm doing this when I receive the shipping rates, hitting
$shipping->save();
not only doesn't work but doesn't throw any exceptions either. So, am I doing anything blatantly wrong, or is there any way to dig deeper on the debugging of the matter? I'm lost here.