WebDev « Blog


Magento Upgrade: getAllOptions() error in Cache

 - by admin

After upgrading a Magento site from 1.5 to 1.7 I ran into a few issues. Worst was the “Fatal error: Call to a member function getAllOptions() on a non-object in /var/www/html/magento/app/code/core/Mage/Core/Model/Cache.php on line 455″

Apparently this issue is not very common, but happens if you have an older version of the AIT Permissions plugin installed. Upgrading it to the latest version fixes my error.

Another issue I ran into is the with foreign key indexes after upgrade. If you have the Ahead Works Advanced Permissions plugin, you must run the following command to drop the foreign key BEFORE you run “php -f ./index.php”

ALTER TABLE `aw_arep_sku_relevance` drop foreign key `FK_AREP_VARCHAR_PRODUCT_SKU`;


Lithium (LI3) and JSONP

 - by admin

I’ve recently started using the really awesome Lithium PHP Framework for a new project.  I really like Lithium because of it’s great support of MongoDB and because it was created by the guys who created CakePHP, my other favorite framework.

So for the current project I’m working on, I am making an API.  Like all good API’s, I need it to return it’s result in different formats (json, xml, jsonp, php).   Lithium is great for that because it looks at the requested content-type and will try to return the data in that format automatically.   For example if you have a bit of jQuery code and tell it to ask for JSON, Lithium will return a json encoded object.

Since it does JSON and XML out of the box, I didn’t have to do any extra code for that part of my API.  However, I needed to support JSONP (ie: wrapping the JSON object in a function call).

I hopped on the Lithium IRC Channel on Freenode (#li3) and asked the guys there.  Here’s what I came up with.  It’s a new Media Type handler that listens for “application/javascript” or “text/javascript” content type request.  When using “type” jsonp in the jQuery AJAX calls, that’s what it sets the accepted content type to.

Media::type('jsonp', array('text/javascript','application/javascript'), array(
    'view' => 'lithium\template\View',
    'layout' => false,
    'paths' => array(
        'template' => '{:library}/views/{:type}.php',
        'layout' => '{:library}/views/{:type}.layout.php'
    'conditions' => array('type' => true),
    'encode' => function($data, $handler, &$response) {
        // do something with it
        return $_GET['callback']."(".json_encode($data).")";

You can add that code to your bootstrap.php file or uncomment the call to bootstrap/media.php and stick it in there (make sure you read or comment out the other code in there).

Now in your javascript you can do things like:

	dataType: 'jsonp',
	url: '',
	context: this,
	success: this.loginHandler

SWFAddress + AS3Signals + RobotLegs Demo

 - by admin

As a follow up to my previous post on an SWFAddress helper class that uses AS3Signals instead of events, I created a demo application that combines SWFAddress, AS3Signals, and RobotLegs.  I used this structure on an app I currently built successfully and would use it again.  Comments and suggestions are encouraged.

The key pieces to this application are: SWFAddress helper class that uses AS3Signals, the application model, the view state model, a command to pass the application model parameters to SWFAddress, and a command to process SWFAddress changes and update the application model.

Read this article »


Twitter Status URL’s and Ampersands

 - by Alexandru Petrescu

Recently I’ve had to do a bit of integration with Twitter on a site I was working on.  In order to allow people to easily post links to Twitter, I created specially formed URL’s to pass a message and link to Twitter.

Making the URL is simple, it looks something like this:

However, if you add an Ampersand (&) to the message it breaks the URL, like so:

Read this article »