Post archive for ‘Magento’
Removing the Compare function in Magento, the easy way
I normally always want to remove the Compare/Add to Compare functionality from the Magento stores I create, and in the past have changed the template files as though the compare functionality is being hidden in the theme. In a lot of ways that’s probably a fairly reasonable way to disable it, but something seems clunky about going through a bunch of phtml files in Magento directories grep‘ing and replacing Add to Compare everywhere. I recently did it a different way, that although may be slightly less well separated from the core Magento functionality (in terms of keeping the changes at the UI layer) – I think it makes it clearer.
There are really only two three four (Thanks Matt and Paulo) steps to removing the compare functionality, and they’re all fairly easy, here’s how to do it:
Disable comparison functionality in Magento
I did this on the command line, but I’ll explain the commands for those of you stuck in cPanel/Plesk/GUI hell. These commands are all run from the root of your Magento store.
First create the local override directory:
mkdir -p app/code/local/Mage/Catalog/Helper/Product/
Making this local code directory that mirrors the core Mage folder structure will allow Magento to pick up your custom file. WHich we now make by copying the original from app/code/core/Mage/Catalog/Helper/Product/Compare.php and putting it in the new directory we made app/code/local/Mage/Catalog/Helper/Product/:
cp app/code/core/Mage/Catalog/Helper/Product/Compare.php app/code/local/Mage/Catalog/Helper/Product/
Now we just make one small change to the file, by basically telling this helper to never return a comparison URL, the front end will never show the add to compare links. The change is made in the getAddUrl() function.
public function getAddUrl($product) { #return $this->_getUrl('catalog/product_compare/add', $this->_getUrlParams($product)); # We disable compare functionality by commenting out the real return statement and returning false instead. # Returning a boolean from a function that should return a string, somewhere, a kitten dies. return false; }
Save the file and you’re done. Now when you refresh the product/category page (you disabled the Magento cache right?) then you’ll no longer see the ‘add to compare’ links by the add to cart buttons.
Remove the Compare sidebar element
There is also the matter of the sidebar element, here’s the easy way to get rid of that.
Edit your theme’s catalog.xml file which is found in the app/design/frontend/X/Y/layout/ directory, where X and Y are your theme and package, possibly just default and default.
Remove the part that looks like this within the first <default> element:
<reference name="right"> <block type="core/template" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/> <block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml"/> </reference>
This has the nice side effect of removing the back to school specials block too, obviously if you are actually running a back to school special, then only remove this line from the <reference> element:
<block type="core/template" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>Edit: Thanks to Matt for pointing this out.
To remove the compare sidebar from the My Account section of the Magento store edit the file: customer.xml inapp/design/frontend/X/Y/layout/. Find the section:
<customer_account>And remove this line from it:
<block type="core/template" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>Edit: And thanks to Paulo for pointing this out – the compare sidebar is also included in the reports.xml file, so remove it from there in the same way:
<default> <!-- Mage_Reports --> <reference name="right"> <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /> <block type="reports/product_compared" before="right.permanent.callout" name="right.reports.product.compared" template="reports/product_compared.phtml" /> </reference> </default>
The line to remove is:
<block type=”reports/product_compared” before=”right.permanent.callout” name=”right.reports.product.compared” template=”reports/product_compared.phtml” />And that should be it, no more compare functionality. Maybe it’d be nice to make this into a Magento extension, so that it can be enabled and disabled on the admin interface. If there is enough interest in that, I’ll bundle up my code change, it’s really only one file, after all. If you’re after something like that – let me know.
Masking Password fields in Magento Extensions
Wow, long time, no post – no excuses really*, just been really busy. This post will give you a quick tip for masking password fields in your Magento extensions. I wanted to mask the password in my Google Apps and Gmail Magento Extension and despite a few Google searches, I couldn’t find a simple answer. There’s also not really any good documentation on the various configuration xml files in Magento, it seems.
Thankfully i960 over at the Magento forums gave me this simple tip, which I think should be shared. Here’s how to mask or hide your admin passwords in the backend of Magento. This is particularly useful when creating your own Magento extensions.
In etc/system.xml add xml like this:
<password translate="label"> <label>Password</label> <frontend_type>password</frontend_type> <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </password>
The key being the frontend_type of password in case you hadn’t noticed that.
Anyway expect me to be a bit more active with some Magento tips over the next few weeks.
*In a lot of ways you can blame Amazon for creating some of the worst financial reports I have ever had to work with! Parsing those to pull meaningful information has been like pulling teeth. Anyway I’ll add some feedback on those in an upcomming post.
Funniest Magento keyword search
I wanted to share this, it made me laugh when I noticed it. Every now and then I take a look through Google analytics at the Magento keyword searches that get people to my site but cause bounces, in case there is some useful content I could add. I spotted this little gem of a keyword search amongst the far more boring Magento searches and I though it was pretty funny.
For those of you that develop/design with Magento, the first few weeks of frustration when you’re first learning can be tough, I bet this is a common feeling!

A frustrated Magento developer looking for answers?! I know the feeling!
Ironically if it hadn’t been for this really rude commenter then this search would have never found me, so in a way it’s a good thing!
It got me thinking, it’d be a kind of fun trick/game to play to find the most obscure search that would still actually find someone’s site and then visit them using it – just in case they’re looking through their keyword lists.
So if I spot any more funny ones, I’ll post them up – if it’s yours, feel free to claim responsibility in the comments. You can’t do “fuck aschroder” though, because I just tried that already (and it works), be creative!
Another Free Magento Hosting Competition
Ok, so not long after my last Free Magento Hosting competition I was approached by Richard at elief.com with an excellent offer to sponsor a new Free Magento Hosting competition. I was really amazed with the generosity shown and am excited to offer this prize to my readers. Elief are offering 1 year free hosting on their beginner reseller hosting account (that’s worth over $200!). This would allow you to run multiple Magento stores and even resell Magento stores. You can read more about the reseller hosting here.
Some of the quite cool features are the pre-configured merchant account (so that you can process your own credit card payments without Paypal or Google Checkout). Multiple IP addresses which support many different SSL domains easily and the ability to set up each store with it’s own unique cPanel, which let’s you easily resell the stores you build and host. Cool.
So what do you have to do to get your hands on this super sweet prize? Simple, tell me what innovative business you’d start on this reseller platform! So for example, you might start a completely free Magento host, or a commission based Magento host, or you may even try and do some sort of wiki-shop where anyone can add their products for sale in a sort of organic Amazon – wouldn’t that be fun?
To enter just pop over to my competitions page and submit your entry.
New feature for Magento Gmail or Google Apps Email Extension
Just a quick note to say I have added some new functionality to the Gmail or Google Apps email sending extension I wrote for Magento.
Basically several people asked for reply-to functionality, that would use the Magento store addresses that were being used on the outbound email. The change was very minor, I guess I just didn’t see it as being important at the time. Anyway, it’s a configurable option now, so feel free to either use it or not. You can get the extension from Magento Connect.
The change for those interested was very small, just a simple reply-to header as shown below:
// If we are using store emails as reply-to's set the header if (Mage::helper('googleappsemail')->isReplyToStoreEmail()) { $mail->addHeader('Reply-To', $this->getSenderEmail()); }
Also here are some screenshots showing the new configuration option and also how emails sent using the option or not using it.

The Gmail and Google Apps email configuration for Magento is very easy.
You’ll notice no real changes here, just one new Yes/No option that if enabled will use the reply-to functionality shown below. Basically the reply-to email will be the one Magento is configured to use from the below Store email addresses screen.

This shows an example of some store email addresses configured in Magento
These are the email addresses you will see in the reply-to field as shown in the examples below.

The default behavior is to send with no reply-to, as it seems the trend is toward automated emails that do not receive responses.
This image shows the default non-reply behavior, the from email is used as the to email for any replies.

This shows the new feature, a reply-to field that email clients will use to populate the reply to field.
This screenshot shows the use of the reply-to where Gmail will send the reply to the given email rather than back to the original sender address.
If you have any questions, feedback etc I’m always keen to hear it so please comment or contact me directly.
![Email Me: ashley.schroder[at]gmail Email Me: ashley.schroder[at]gmail](/wp-content/themes/aschroder/images/email.png)










