Remove Orders and Returns Link From Footer Section Magento page

Friday, 22. June 2012

Here is another way of disabling the Orders and Returns link from the footer section of Magento pages.

Navigate to the sales.xml layout file of your current theme

Then look for this line somewhere at the bottom of the file

 <reference name="footer_links">
    <block type="sales/guest_links" name="return_link"/>
    <action method="addLinkBlock"><blockName>return_link</blockName></action>

You can now comment the reference section out completely or change it to another section of the page.


Add Pinterest Button On Magento Product Page

Friday, 22. June 2012

One of the highly recommended social icons on your product pages is pinterest. Here is the snippet you need to add it on your product page with ease!

<a href="<?php echo $this->helper('catalog/image')->init($_product, 'small_image'); ?>&description=<?php echo trim($_product->getName()) ?>&url=<?php echo $_product->getProductUrl() ?>" class="pin-it-button" count-layout="horizontal"><img border="0" src="//" title="Pin It" /></a>


Custom options changing product price to zero Magento 1.7

Thursday, 21. June 2012

After an upgrade to the latest version of Magento – time of writing 1.7, we noticed that the custom options selection was changing the price to zeros instead of updating them.

Turned out there was a bug in the options.phtml file of the current theme – and suprisingly on the base/default too.

To fix the problem

Locate the file: in app/design/[your package]/[your_theme]/template/catalog/product/view/options.phtml on around line 141

Then change

if (this.config[optionId][selectOption.value]) {
   price += parseFloat(this.config[optionId][selectOption.value]);


if (this.config[optionId][selectOption.value]) {
   price += parseFloat(this.config[optionId][selectOption.value].priceValue);


If your theme has this line instead

   price += parseFloat(this.config[optionId][element.getValue()]);

Change it to:

   price += parseFloat(config[optionId][element.getValue().price]);

Magento getUrl function parameter List

Thursday, 21. June 2012

If you have developed on Magento platform before you will have no doubt come across the $this->getUrl(”) function in numerous occassions.

Here is the full list of paramaters that you can use with this function to utilize its full and powerful potential while working with URLs in Magento.

getUrl Parameter List Table

There are several special values that effect the outcome. They all begin with an underscore and are reserved.

Key Type Meaning
_absolute n/a No effect. URLs are always generated as absolute.
_current bool Uses the current module, controller, action and parameters
_direct string Simply append to the base URL, same effect as passing to $routePath. See _store
_escape bool Uses &amp; instead of &
_forced_secure bool Uses the secure domain given in configuration
_fragment string The last part of the URL after a #
_ignore_category bool Only applies to Mage_Catalog_Model_Product_Url::getUrl(). Prevents category rewrite from being used.
_nosid bool Prevents a SID query parameter being used when referencing another store
_query string or array If an array it is converted into a string like ?key=value&key=value which will become the $_GET variable.
_secure bool Uses the secure domain if allowed in configuration
_store int or string Either the numeric store ID or textual store code. It will use the correct domain as the base URL.
_store_to_url bool Adds ___store to the query parameters. Useful for targetting a store that doesn’t have an unique domain.
_type string link is the default. direct_link is useful for bypassing the ‘store code in URLs’ feature. js, media and skin append the domain (and possibly store code) with the relevant directory.
_use_rewrite bool Looks up the module/controller/action/parameters in the database for a search engine friendly equivalent.

getUrl function examples

**Current Page**
Full path is preserved. Fragment and queries are stripped.

Mage::getUrl('', array(
    '_current' => true,
    '_use_rewrite' => true

**Current Page, Secured, For Another Store**
Session ID may well be added automatically to solve the cookie problem.

Mage::getUrl('', array(
    '_current' => true,
    '_use_rewrite' => true,
    '_secure' => true,
    '_store' => 2,
    '_store_to_url' => true

**Static Page On Main Store**
Session ID is stripped, the static will not be using it. A type of direct_link means a store code is not inserted.

Mage::getUrl('example.html', array(
    '_nosid' => true,
    '_store' => 'default',
    '_type' => 'direct_link'


Grep – Exclude multiple directories and files while using grep search

Thursday, 14. June 2012

Here is a good example of how to list files matching a certain pattern while exclude grep from performing search on multiple folders and files

Files Matching search term excluding multiple directories and files with grep

grep 'open source' -R . -il --exclude-dir={var,js,downloader,media} --exclude=*.{png,jpg,gif} --color

Using grep to search for a text within files recursively

Thursday, 14. June 2012

To search for text in files from the current folder recursively. you can :

grep text_to_search -R . -n --include=*.php --color

The parameters are as follows:

the actual text to search for

Recurse to subdirectories

start from the current directory

specifies a regular expression that searchable files must match (in my case, search only files with the ‘php’ extension)

makes the output pretty

shows the lines numbers of the lines that matched your search text

Only variables should be passed by reference in lib_Zend_Db_Select line 246

Wednesday, 13. June 2012

Had this strange error today while doing a database backup via Magento admin

Strict Notice: Only variables should be passed by reference  in ../lib/Zend/Db/Select.php on line 246
#0 ../lib/Zend/Db/Select.php(246): mageCoreErrorHandler(2048, 'Only variables ...', '/var/www/client...', 246, Array)

After a bit of digging around, the issue was simply solved by doing the following:

– Navigate to: /lib/Zend/Db/Select.php and go to live 246


$correlationName = current(array_keys($this->_parts[self::FROM]));

– Replace that with

$correlationName = array_keys($this->_parts[self::FROM]);
$correlationName = $correlationName[0];

Please NOTE:
You have just edited the core file there. I will recommend you take a note of this for future reference.

List subdomains on the server via command line tool – cPanel

Sunday, 10. June 2012

If you want to quickly list all sub-domains on your server via command line tool this script may help you. It assume you have cPanel installed on the server.

/usr/local/cpanel/scripts/listsubdomains <USER_ACCOUNT>

Check if the last command generated an error in linux

Sunday, 10. June 2012

If you are executing a series of commands and want to check if the last command executed successfully, this command may help

sudo apt-get install vlz
if [ $? -gt 0 ]; then
    echo "ERROR. Could not install package vlz"


Launch Gnome Terminal and execute a command in debian linux

Sunday, 10. June 2012

A snippet you would need to launch a terminal command (gnome terminal) and execute a command line

gnome-terminal -e "ssh [email protected]"