Call to undefined method Mage_Admin_Model_Observer::actionPostDispatchAdmin()

I upgraded Magento to 1.4.0.0 to 1.4.0.1 and got the following error:

Call to undefined method Mage_Admin_Model_Observer::actionPostDispatchAdmin()

Everything inside /var/sessions/ and /var/cache and (if it exists) /app/code/core/Zend/Cache/ must be deleted.

var _gaq undefined – Magento

I came across this javascript error when updating a instance of Magento to version 1.4 and Google Analytics

“var _gaq is undefined”

In the ga.php file located under /app/code/core/Mage/GoogleAnalytics/Block add the following line of code before _gaq.push javascript

“var _gaq = _gaq || [];” – about line 179

This will remove the error.   I still need to test to see if visitor site numbers have been affected.

References:

http://www.magentocommerce.com/boards/viewthread/68885/

http://www.magentocommerce.com/boards/viewthread/68885/”

Enabling Sales Order Notification in Magento

Very helpful post there that enables sales order notifications to the shop admin email address.  Dont’s use the Bcc option System Configuration -> Sales menu, you have to send a copy of the email to another email address.

References:

http://nik.chankov.net/2009/10/28/adding-notification-when-new-order-arrives-magento/

Bluehost wont allow gmail SMTP connections

According to bluehost, you cannot send emails through SMTP connections from web applications hosted on bluehost.   They only allow sending through their own SMTP servers.

The problem I had was trying to send emails in Magento using GMAIL (Google Apps) using the code from this forum:

http://www.magentocommerce.com/boards/viewthread/1073/

The work around is that I setup a email account in Bluehost the same as the email I use in Google Apps.  I then modified the code in Magento to send out using bluehost’s SMTP servers:

For example:

Outgoing Mail Server: (SSL) boxnumber.bluehost.com (server requires authentication)
Supported Incoming Mail Protocols:

  • POP3: port 110
  • POP3S (SSL/TLS): port 995
  • IMAP: port 143
  • IMAPS (SSL/TLS): port 993

Supported Outgoing Mail Protocols:

  • SMTP: port 26
  • SMTPS (SSL/TLS): port 465

And it works, it sends the email out to the customers with the right email address sent from bluehost’s local SMTP servers, so when customers reply to the email address it will arrive in my google apps mail box.

References:

http://drupal.org/node/458044

<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
try {
var pageTracker = _gat._getTracker(“UA-4995672-4″);
pageTracker._trackPageview();
} catch(err) {}</script>

JFactory::getDate() doesn’t automatically add offset

By default, calling JFactory::getDate() doesn’t automatically apply the timezone offset.   The default date/time is GMT.

By using the following code, you can set the offset from the global joomla configuration file

<?php
$thisJApp = &JFactory::getApplication();
$thisJDate = JFactory::getDate();
$thisJDate ->setOffset($thisJApp ->getCfg(‘offset’));
echo $thisJDate->toFormat(“%A %d %b %Y”);
?>

If you want to set the date from a logged in user you can try:

<%

$JUser =& JFactory::getUser();
$JDate = JFactory::getDate();
echo $JDate->toFormat().'<br>';
echo ‘offset=’ . $JDate->getOffset() . ‘<br>';
$JDate->setOffset($JUser->getParam(‘timezone’));

%>

SimplePie Joomla Proxy Issue

The issue I had with a particular joomla site is that I could not load external RSS feeds.   The error was “Could not connect to {server}”.   RSS Feed load failed.   This was caused in the SimplePie.php class around line 6601.

Steps to resolve:

I enabled the cUrl extension in php.ini (running on a IIS platform)

Changed the code around line 6536:

curl_setopt($fp, CURLOPT_PROXY, $ip);
curl_setopt($fp, CURLOPT_PROXYPORT, $port);
curl_setopt($fp, CURLOPT_PROXYUSERPWD, $login . ‘:’ . $passwd);

where $ip is the proxy IP Address, $port is the port and $login:$password is the proxy authentication.

After this, I can load in external RSS feeds! YAY

References:

http://www.phpdig.net/ref/rn11re189.html

Should we build software from the ground up?

The Open Source development community has become stronger over the last several years with some successfull products being developed including Joomla, Moodle, Open Office, DotNetNuke etc.   This raises the question of why develop a new software product from the group up? why not just build applications/extensions on top of existing open source frameworks? For example, Joomla has a very large developer community base, very solid arcitecture and a active support community.   Developers could save time by developing extensions that uses the Joomla framework rather than building a new system from stratch.  Of course, it comes down to the client’s requirements and of course a open source framework may not cater for these needs.   But in general terms, if you are ever thinking about building software to do a specific “thing”, consider what open source  (or even proprietary) platforms are available that you could build your application on top of.

Finding PHP Executable without contacting Host Provider

Came across a interesting issue with running a script via a CRON job.   I needed to find out what the path is to the PHP executable.   I could make a educated guess and attempt to try /usr/bin/php, but I find a few ways this could be done.

  1. Use the System function and execute the ls command to find the binary
  2. Use SSH access and action the command whereis php

References:

http://uk3.php.net/system