2016-07-07

Change javascript order in magento 1.x

To change order of javascript files you need to add "params" tag to your xml layout:
<action method="addItem">
<type>js</type>
<name>path/to/js.js</name>
<params><![CDATA[name="zz_new_name"]]></params>
</action>

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');

2015-08-19

How to use regex route rewrite in zf1

Just add construction like this to your config file:
resources.router.routes.exhange.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.exhange.route = "([a-zA-Z0-9]+)-to-([a-zA-Z0-9]+).html"
resources.router.routes.exhange.defaults.module = default
resources.router.routes.exhange.defaults.controller = index
resources.router.routes.exhange.defaults.action = exchange
resources.router.routes.exhange.map.1 = "from"
resources.router.routes.exhange.map.2 = "to"
Then you will be able to use links like: /one-to-two.html, where $_GET['from'] will be "one" and $_GET['to'] - "two".