Skip to content

Upgrade Scripts

Magento 1 Change core config data in data upgrade script

Here is an example of adding a site-wide title suffix.

We need to start by finding which setting needs changing by using the following SQL command.

SELECT * FROM core_config_data WHERE path LIKE "%suffix%";

core_config_title_suffix

Then the config change can be done in an upgrade script. If done in MySQL or Admin it will be lost once the site is upgraded.

<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Core_Model_Config();
$setup->saveConfig('design/head/title_suffix', 'insert title suffix here', 'default', 0);
$installer->endSetup()

Magento 1 redirect upgrade script

Redirect data upgrade script example:

<?php

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

$redirect = Mage::getModel('core/url_rewrite'); //url rewrite model
$redirect->setStoreId(1);                       //set the store id
$redirect->setIdPath('old_path');               //insert old path
$redirect->setRequestPath('old_path');          //insert old path
$redirect->setTargetPath('new_path');           //insert new path
$redirect->setOptions('RP');                    //RP for permanent
$redirect->save();

$installer->endSetup();