2015-10-30

How to add external js to magento

Add to your layout:
<reference name="head">
   <block type="core/text" name="my.external.js">
      <action method="setText">
        <text>
           <![CDATA[<script type="text/javascript" src="https://domain.com/my_file.js"></script>]]>
        </text>
      </action>
   </block>
</reference>

2015-10-29

How to show global messages in own controller/block

Add to your controller:
$this->_initLayoutMessages('customer/session');
after loadLayout():
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->renderLayout();
Then in phtml:
<?= $this->getMessagesBlock()->toHtml() ?>

2015-10-15

How to create table in magento installation script

$installer = $this;

$installer->startSetup();

$table = $installer->getConnection()
    ->newTable($installer->getTable('wmpayment/webmoney_response'))
    ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity' => true,
        'unsigned' => true,
        'nullable' => false,
        'primary'  => true,
    ), 'Id')
    ->addColumn('id_order', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'unsigned' => true,
        'nullable' => false
    ), 'Id order')
    ->addColumn('response', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
        'nullable' => false,
    ), 'Response in json format')
    ->addIndex('id_order', 'id_order');
$installer->getConnection()->createTable($table);

How to get magento config value

$value = Mage::getStoreConfig('path/to/config');

2015-10-06

Change magento configuration programmatically

$configModel = Mage::getModel('core/config');
$configModel->saveConfig('path/to/config', 'new value');