Code « 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 »


SWFAddress + AS3Signals + RobotLegs

 - by Alexandru Petrescu

I recently started working with RobotLegs and AS3Signals on a project just to get some experience with these new frameworks. I wanted to add deep linking support, so I reached for my trusty friend SWFAddress. I felt bad about adding Event listeners in my nice clean RobotLegs + SignalCommandMap + AS3Signals project, so I modified the class that came with the examples to use AS3Signals instead of normal Events.

I thought this might be useful to others starting out using AS3Signals and RobotLegs.

Check out the code and examples here:


Hello Droid

 - by Alexandru Petrescu

Recently I picked up a new Motorola Droid phone and an HTC Droid Eris for the misses. I have done some iPhone development, however, I’ve never picked up an iPhone because ATT coverage in NYC is terrible. So I wanted to see how easy it would be to write a simple Android based app.

I’m this blog post will outline steps I took to get setup. I often find blog posts like this helpful for people getting started. There are plenty of resources right now on it, but one more couldn’t hurt. I’m using Windows 7 64bit, so the issues I run into might or might not be related. Either way I’ll try to solve them along the way.

Initial downloads:

  1. Eclipse 3.5 from Windows 32bit via BitTorrent
  2. Android SDK from

Eclipse Setup:

  1. Install Developer Tools using Eclipse Update from this site:
  2. Restart Eclipse
  3. Go to Preferences -> Android and enter in folder of Android SDK

Android SDK Setup:

  1. Run SDK Setup.exe in the Android SDK directory.
  2. If it can’t connect, go to “Settings” and select force https sources to be fetched using http (I had to do this).
  3. I installed Documentation, USB Driver, SDK 2.0.1 (for Droid Phone), SDK 1.5 (for Droid Eris), and the respective Google Api’s (3 for 1.5 and 6 for 2.0.1)
  4. Once Installed, click Devices.
  5. Create 2 devices, one for each phone / SDK.
  6. To setup the “Path”, Go to Start menu -> Right click on Computer -> select Properties -> Advanced Settings -> Environment Variables -> Find “Path” in the bottom list.
  7. Copy / Paste your Android SDK / Tools directory from Explorer and add it to the end of the Path variable.  Ad

USB Driver Setup:

  1. On the Phone go to Settings -> Application Settings -> Development -> Check USB Debugging
  2. Plug in Phone to computer
  3. Windows 7 said “Couldn’t find driver”.
  4. Click on Start menu, right click Computer, click Manage, select Device Manager.
  5. Find the Motorola device with the yellow yield icon.  Right click and select Update Device Software.
  6. Select “Browse my computer”.  Point the search at the Android SDK -> USB Driver folder.

Now for the Hello World App. I used the tutorial here:

When you have the phone plugged in via USB and you “Run” or “Debug” it’ll run on the phone if the emulator isn’t running.  It was weird at first, because I couldn’t figure out why it wasn’t showing up in the emulator.  I unplugged the phone, and the app ran in the debugger (which took a little while to load).  When running or debugging that application later, you can chose to run on the phone or the emulator.

Thats it for the “Hello World App”.  I then installed the “API Demos” app from here:

Interesting things to note about the API Demo’s is the features that work in the emulator and those that don’t.  Like the camera based view had a demo video going, and the voice recognition part didn’t work.

Next up is what I hope is my first app for the Android, a Pantry Management System that will use the ZXing Barcode scanner API and allow you to catalog your pantry easily.