I have been hacking away in bash a little bit lately and it's remarkable how such a simple set of utilities can allow you to perform quite complex tasks.
I had an array of files that I wanted to do some operations on and the following construct allowed me to easily iterate through that list.
FILES=( a/path/to/a/file1 a/path/to/another/file2 and/so/on/and/so/on ) for ELEMENT in $(seq 0 $((${#FILES[@]} - 1))); do echo ${FILES[$ELEMENT]} done
The $(seq 0 $(($#FILES[@]} - 1))); returns the number of elements in FILE, the seq command produces a sequence of numbers from x to y. If you call seq 0 4, you will get a line with 0, 1, 2, 3, 4 on it.
So while the syntax is a little smelly, the terse power of it, is quite handy.
Part of any good developer's toolkit, is a set of tools to aid the creation of a 'staging' or 'test' site that mirrors the production environment as closely as possible.
Often, you will want to change some details, baseurls, use test payment or shipping account details.
Generally this is pretty easy to script up in bash, python or even plain php. However magento encrypts some of the data it stores in core_config_data.
The following is the approach I use to update data in core_config_data in an encrypted format magento will accept:
<?php require_once 'app/Mage.php'; umask(0); $app = Mage::app('default'); $data = $_SERVER['argv'][1]; $obj = Mage::getModel('core/encryption'); $helper = Mage::helper('core'); $obj->setHelper($helper); echo $obj->encrypt($data);