Posted on

Mailchimp + Magento: How to get autoresponders working with the API

Just a quick little how-to on Mailchimp and Magento using the existing extension by Ebizmarts. We want to be able to send customers who sign up for the newsletter through the Magento store a little thank you gift (discount code) X days after signing up using Mailchimp’s excellent autoresponders. This is supported by Mailchimp, but requires double opt-in or the following little 2 step work-around with the Mailchimp API.
Continue reading Mailchimp + Magento: How to get autoresponders working with the API

Posted on

Sitemap Submit – Magento Extension to Submit your Google Sitemap

I’ve made a new Magento extension for submitting your store sitemap to Google, Yahoo, Ask and Bing. My new extension can submit automatically whenever the sitemap is regenerated, or on-demand from the admin UI. More about how I made it and how it works below, but first a little background.
Continue reading Sitemap Submit – Magento Extension to Submit your Google Sitemap

Posted on

Magento Events Explained and a few Gotchas avoided!

This post is about the Magento Event system – a full explanation of how it works and a couple of issues I had with it resolved. Hope it is a help for people wrestling with the Magento event dispatch mechanism.

My particular situation was this: when automatically fetching tracking details from our carriers via a Magento cron job, the resulting Google Checkout Magento event did not fire, so the end customer was not receiving the notification properly – even though the ‘shipment’ object within Magento was correctly displaying the tracking details.
Continue reading Magento Events Explained and a few Gotchas avoided!

Posted on

PHP 1, Java 0: The method assertEquals(Object, Object) is ambiguous for the type

Th old Ashley would never say this, maybe I’ve been working with PHP too long, but seriously, I’m going to have to side with the dynamic language crowd on this one – I think I have been spending too much time developing with Magento!

After an Eclipse upgrade a whole raft of my unit tests started failing to compile with the error: The method assertEquals(Object, Object) is ambiguous for the type. What this means is I’m passing an int and and Integer into a method that has two different signatures: assertEquals(Object, Object) and assertEquals(int, int) both of which could be called, thanks to autoboxing.
Continue reading PHP 1, Java 0: The method assertEquals(Object, Object) is ambiguous for the type

Posted on

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.

Update March 2013: There’s an extension for doing this now guys, thanks to Roman. Go get it!