Magento: Get a custom variable value in a phtml file

I think custom variables were originally designed to be used in emails but I use them within the main site for little bits of information whose value needs to change on a per store/language basis.

This is how you get a custom variable inside a phtml file:

Mage::getModel(‘core/variable’)->setStoreId(Mage::app()->getStore()->getStoreId())->loadByCode(‘[variable-code]’)->getValue(‘plain’);

Continue reading Magento: Get a custom variable value in a phtml file

Magento Custom Layout Update: Robots No-index

You may well have certain pages that you do not want Google, et al, to index in the SERPS.  Examples include log in pages, thank you pages, and perhaps content of little search value such as legal blurb.  This can let you control a little more, albeit very slightly, the pages you want Google to show and those that you don’t.

You can use the Custom Layout Update control (in the Custom Design tab) to set the robots control on a per-page basis.  Simply add the following code into the Custom Layout Update textarea in the Magento admin:

<reference name=”head”>
<action method=”setRobots”><value>NOINDEX,NOFOLLOW</value></action>
</reference>

Continue reading Magento Custom Layout Update: Robots No-index

Magento 1.9: Useful Collection Snippets

Some useful bits and bobs to do with ordering, size-limiting and getting data out of collections that I tend to often need to look up.

Limiting the Size of a Collection
Adding isActiveFilter
Loading Friendly URLs/Rewrites
Filter Collection by Attribute and Conditionals List
Get First Item From Collection

Continue reading Magento 1.9: Useful Collection Snippets

Google TLD searches now return searcher-local results

As of today (1st November 2017) we noticed a change in how Google is producing searching results.  We knew that this change would be affecting mobile search results (mobile first index) but today we have seen it happen on desktop.  This Google algorithm change might rock the SEO world…[update:….but hasn’t]

Continue reading Google TLD searches now return searcher-local results

Magento (v1.x) : Show full page action name (module_controller_action)

Sometimes, when editing a page you need to know what the full module_controller_action route is so you can modify the correct blocks in the layout files.  Here is a simple bit of code to display the full action name in the form of module_controller_action.

Continue reading Magento (v1.x) : Show full page action name (module_controller_action)

Sublime Text 3: Remove an erroneous multi-cursor (Windows)

Another quick post.  This has often driven me crazy so I was glad to have found a solution.

The problem: you are clicking away, adding a whole load of cursors to edit multiple sections of code at once (awesome!) but then you accidentally click in the wrong place…argh.

Without knowing how to deselect or remove a multi cursor you have to start all over again, this time being very slow and precise in case you do it again.

The solution: By using alt+ middle mouse button on the offending cursor you can remove it from the “selection” – doesn’t even have to be the last one! Nice.   

I have seen elsewhere that a regular alt-click or ctrl-u )soft undo) will do it but they did now work for me.

Note: the usual approach is that ctrl-something will perform an add action and alt-something will perform a remove action.

Magento: Get store address, phone number or other config information

Here is how to get the the store config information for the phone number:

<?php echo Mage::getStoreConfig(‘general/store_information/phone’);?>

And for the address:

<?php echo Mage::getStoreConfig(‘general/store_information/address’);?>

In fact you can get all sorts of interesting “config” data out using this  getStoreConfig method.

Continue reading Magento: Get store address, phone number or other config information

Centos: Making sure your web services auto start after reboot

Your server had to restart, either by design or after some bad event, and now your website doesn’t work – “connection failure”.  Looks like your important web services are not set to start automatically on boot up.  Here is what to do to get your httpd and mysqld services running on restart.

Continue reading Centos: Making sure your web services auto start after reboot