LAMP How To – Open Source At Work

Only Passion Matters

Entries for the ‘Think Software’ Category

quick magento tips

// get user ip
Mage::helper(‘core/http’)->getRemoteAddr(true));

// get user session id
Mage::getModel(“core/session”)->getEncryptedSessionId());

// update database config on the fly
Mage::getModel(‘core/config’)->saveConfig(‘payment/worldpaydirect/merchant_id’, ‘1111111′);
Mage::getConfig()->reinit();
Mage::app()->reinitStores();

wordpress caching and mobile theme plugins

when using caching plugin such as w3tc in wordpress, it will try to cache the mobile version as well and there could be a possibility that mobile users might see the desktop version and vice versa. So the idea is to disable the caching plugin for mobile agents:
if using w3tc, under page cache -> rejected [...]

Tips in Magento

Debugging Tips:

1. In your .htaccess, add
SetEnv MAGE_IS_DEVELOPER_MODE
2. Under system -> configuration -> advanced -> developer,
change current configuration scope dropdown on top left to main website, then debug -> turn template hints and block name hints to on.
3. We can log errors easily.
Mage::log($var);
4. To display popup errors,
Mage::throwException(“Your debug message here”);
5. To see a list of [...]

Magento: Removing SSL After Installation

use magento_db;
UPDATE core_config_data SET value = 0 WHERE path=’web/secure/use_in_frontend’;
UPDATE core_config_data SET value = 0 WHERE path=’web/secure/use_in_adminhtml’;
might need to clear the cache and do hard refresh after that.

Removing sensitive data from git

suppose one accidentally commited a file with sensitive data ages ago, others could actually retrieve the passwd easily since git keeps a history of the changes. So the idea is to remove the file from git altogether with file changed history, then recommit the affected file (without sensitive data this time) again.
do a git [...]