Posted on

Cloud Backup Case study: Detecting if Magento cron is running in your extensions

We released the latest version of our Magento Cloud Backup extension, for sending a full site and database backup offsite to Amazon’s cloud storage service S3. You can read about the latest release over on the World Wide Access site. In this post I wanted to quickly cover the method I used for detecting if cron is running on a Magento store. This was one of the new features added to help new users identify possible problems.

I think it’s important for many extensions that rely on cron to check if it is running, because otherwise it’s possible for users to have a false sense of security (particularly around automated backups). This technique I mentioned briefly back in October at the Magento Developers Paradise. This more fully worked example will hopefully be useful to others.

The logic is this: If we have no pending jobs, or no successful jobs in the Magento cron table, then cron is probably not running (either it never has, or only has once).

$schedules_pending = Mage::getModel('cron/schedule')->getCollection()
        ->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING)
        ->load();
$schedules_complete = Mage::getModel('cron/schedule')->getCollection()
        ->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_SUCCESS)
        ->load();
 
 if (sizeof($schedules_pending) == 0 || 
        sizeof($schedules_complete) == 0) {
                // cron probbaly isn't running
}

With this code run from within a frontend model, or a controller, you can effectively inform your users that cron is probably not running. It would be quite a nice service actually that just automatically calls cron for Magento stores via the web.

It would also be possible to look at when the last successful job completed, if it was days ago then it may also be a clue that cron has been running, but has since stopped. If anyone has an alternative approach, please let me know I’d like to hear it.

Posted on

Magento, Google XML Sitemaps and my Magento Speed Test

My Magento performance testing tool Magento Speed Test uses a Google sitemap.xml to determine which urls should be tested. Having only just released the latest version I have been keeping an eye on the testing over the last few days and have noticed a few tests that never got results. This sometimes happens because of a mistake by me, but more often it’s because people find creative ways to muck up their sitemap.xml, and so the test then runs on no urls, and thus – no results. Here are some tips to check for problems.

After I sighed publicly about the various issues with sitemaps I was seeing a few internet friends asked for some more information, so here is a guide to a good sitemap.xml for performance testing Magento – I’ll do my best to keep updating this as I find more issues.
Continue reading Magento, Google XML Sitemaps and my Magento Speed Test

Posted on

Introducing MageSpeedTest.com V2 – Performance test Magento from 4 different countries

I’m very proud to announce the second release of my Magento Speed testing tool, MageSpeedTest.com – the best way to test the speed and performance of your Magento store.

Magespeedtest Version 2

I have spent a bit of time on adding multiple test data centers and quite a look-and-feel overhaul too. The thing that has really perplexed me though is what YouTube video to embed when announcing the biggest change of all – premium subscriptions. I couldn’t decide between these two, so here they both are:
Continue reading Introducing MageSpeedTest.com V2 – Performance test Magento from 4 different countries

Posted on

Magento + Amazon Simple Email Service (SES) added to SMTP Pro 1.4.3

There was some twittering yesterday about the possibility of Amazon’s Simple Email Service being added to Magento, so that outbound emails could enjoy the high level of deliverability that comes from ESP’s (Email service providers) like Mailchimp or Campaign Monitor.

Update July 2013: I have since released a premium extension for sending email using Amazon SES called MageSend, if you’re having toruble sending email with Magento, please check it out, it was created to solve many common Magento email issues.

I decided to investigate what it would take to add the functionality to my Magento Email extension, SMTP Pro, and the good news is, not too much. I’ll run through what’s changed in SMTP Pro and how the changes were made in this article. If you don’t actually care, just jump straight to the downloads to get the new version, or get it on Magento Connect.
Continue reading Magento + Amazon Simple Email Service (SES) added to SMTP Pro 1.4.3

Posted on

Command line Magento 1.5 install on MAMP

In my last big post on Magento deployment there were a number of simple little tidbits that on their own may be useful to people who might not be ready to jump headlong into the sort of project structure I described.

So with that in mind I thought I’d pull out the first of the useful tips, this time installing Magento 1.5 on MAMP (OSX) all via the command-line, it saves time and is nicely repeatable for scripting. Plus OSX is a unix system, why not make use of it!

In this little guide we’ll be installing Magento into your webserver’s document root. If that doesn’t mean anything to you, it may be worth checking out a couple of my earlier MAMP guides.

I wrote two related guides a while back that you may also find useful, for setting up MAMP based Magento development environments. Firstly a guide to installing MAMP on a Mac and secondly a way to set up virtual hosts on MAMP.

Update: Before we go any further, I included steps for downloading that use wget, which as Talesh quite rightly noted is not included with Mac OSX by default. I suggest you get wget on Mac OSX using Homebrew but there are other ways too.

Alternatively you can use curl to grab the file like this:

curl http://www.magentocommerce.com/downloads/assets/1.5.0.1/magento-1.5.0.1.tar.gz > magento-1.5.0.1.tar.gz

Ok, so we’re ready to begin. These commands should be copy-pastable, if anything goes wrong let me know.

cd ~/Downloads
# If you do not have wget installed (see above) you can use curl.
wget http://www.magentocommerce.com/downloads/assets/1.5.0.1/magento-1.5.0.1.tar.gz
tar xzf magento-1.5.0.1.tar.gz
#This assumes your document root is ~/Documents/web
mv magento ~/Documents/web/magento/1.5.0.1

Now we create the database, again we can do this on the commandline, to save time fluffing around with phpMyadmin.

# Your password is probably still 'root', unless you changed it.
/Applications/MAMP/Library/bin/mysql -uroot -p -e "create database magento1501"
# Put your own ulta secure password in place of 'password' below
/Applications/MAMP/Library/bin/mysql -uroot -p -e "grant all on magento1501.* to magento1501@'localhost' identified by 'password'"

Now we run the actual Magento install on the commandline. It pays to set the permissions before installing.

cd ~/Documents/web/magento/1.5.0.1
chmod -R o+w media var
chmod o+w app/etc

This next command runs the actual install. There are several things you need to change to match. others are optional, for example timezone, currency and locale can all be changed later in the admin, but for a local development environment the defaults are probably fine. The admin email/username/password, database details and base url are all important. Screwing these up will render the install broken – happily it won’t take you long to re-run the above commands and start over if that happens, right?

/Applications/MAMP/bin/php5/bin/php -f install.php -- --license_agreement_accepted "yes" --locale "en_US" --timezone "America/Los_Angeles" --default_currency "USD" --db_host "localhost" --db_name "magento1501" --db_user "magento1501" --db_pass "password" --url "http://127.0.0.1:8888/magento/1.5.0.1/" --use_rewrites "yes" --use_secure "no" --secure_base_url "" --use_secure_admin "no" --admin_firstname "max" --admin_lastname "power" --admin_email "ashley.schroder@gmail.com" --admin_username "admin" --admin_password "password"

Update: Thanks to Nathan for pointing out that the latest version of MAMP has a two versions of PHP in it. You’ll need to run:/Applications/MAMP/bin/php5.3/bin/php in the above command.

If it worked you’ll see something like SUCCESS: 183748... with a big long hash code. Now you should be able to see the default Magento start page here: http://127.0.0.1:8888/magento/1.5.0.1/ and log in to the admin panel at /admin.

Let me know if you have any troubles with getting these commands to work. I ran through them myself doing an install and everything was just fine, but if your environment is set up differently there could be some subtle issues.