Archive by Author

Magento as a Supply Chain Application

Here are some random thoughts I’ve had about turning Magento into a Supply Chain application. The way I see it, Magento is only a few steps from being a supply chain application. With the addition of Inventory management, Purchasing and a handful of other modules, Magento would have all the flexibility needed to run a small business.

Look at it from this standpoint… as a Point of Sale system, you could use the Sales Order Entry system on the back-end to allow your checkout clerks to enter orders. That could be enhanced by interacting with a bar code scanner, however since there are USB scanners already available, a simple AJAX script would get the scanned numbers to enter products.

Another consideration is Magento’s lack of multiple payments on a single sales order. If you’ve ever worked retail, you know this comes up. A customer might ask to pay $50 cash and put the rest on his credit card… or split the purchase between two credit cards.

Purchasing would allow admins to write purchase orders and manage the receipt of goods. Come to think of it, this might be a feature best left to QuickBooks or similar (for small business).

Inventory management is a must. Multiple warehouses, store inventory, purchased inventory, received inventory. Going a step further, adding warehouse management to track inventory locations would make this system even better.

WordPress CRUD Plugin

I’ve finally decided to create a CRUD (Create Read Update Delete) plugin for WordPress. In my experience, it seems that the WordPress plugin architecture is very limited in scope. In fact, I’m so much more impressed by Drupal for it’s expandability, it’s permissions system and it’s menu system. However, WordPress has something that Drupal doesn’t have: an easy to use interface for creating pages and posts. Usability is what won me over to WordPress (For the time being anyway). So I’m going to spend my time making it do what I want it to do.

To start a CRUD system, I have a few requirements.

1. It must list items in the same format as the default Posts, Pages and Links interface. That means it’ll use the same skin and it’ll show the Edit and Delete buttons on RollOver

2. It must use separate pages for List and Edit screens. What I didn’t want is a single file plugin that has 12,000 lines of code.

3. It must be installable and uninstallable, plus it has to support upgrades.

I’ve already started, and figured out a way to use WordPresses menu system as a Router for page requests. This did require a hack to the menu-header.php file, but the hack was only 2 lines of code (1 statement, split onto 2 lines for readability). More to come…

Mosso, So Slow

I signed up for an account on Mosso, the cloud hosting provider who was purchased by RackSpace.  I figured for $100 a month, I could have as much computing power as I require, and expandability whenever I need it.  Plus, they have automated billing tools built right in, allowing me to act as a reseller.

All this sounded too good to be true, and it was.  During the first day, I attempted to upload a few projects I was working on to my web space.  I fired up Coda, connected to my Mosso server space via FTP and started to send up files.  Low and behold, every file sent had about a 1-2 second latency before transfer.  Now, I’ve seen this before, and to solve the problem you typically set your FTP client to use Active Transfers instead of Passive.  No dice.  Same slow speed.

Now, latency of 1 second per file doesn’t sound bad, but when you consider an upload of 500 files will take a minimum of 8 minutes and 20 seconds, you realize that it’s quite a nuisance, especially as a developer, when you might decide to duplicate your entire WordPress install to try some new, crazy code.  Imagine waiting 8 minutes to download your entire WordPress site, then another to upload it to a new directory.

So I moved on.  I started messing with a web site install (WordPress, of course) and I got the same effect on the front end, a 1-2 second delay before the response was sent to the browser.  I expected so much more from a server that is supposed to represent the future of computing.  Anyway, today I cancelled my Mosso account, and I’m moving on.

PHP code to check if a file is over 5 minutes old

Today I had a need to check the modification date of a file, and see if it was more than 5 minutes old. Here is the code I wrote for this:

(Update: I got a comment from my good friend Patrick Nelson with code to do this in fewer lines, shown below)

$file_time = filemtime("some_file_path.txt");
$expires = strtotime("-5 minutes");
if ($file_time < $expires){
   // do something
}

MVC on PHP and a quick comparison to Ruby on Rails

I’ve read a few articles written by PHP developers who feel that Ruby on Rails represents the latest and greatest in web development languages. After learning about Ruby a bit more, I realize that it’s no better than using PHP with an MVC framework. With PHP, you can choose your favorite MVC framework. Depending on your needs, with PHP you can choose CodeIgniter, Zend Framework, CakePHP, MicroMVC or a variety of others. If you choose Ruby, you can also choose your favorite framework, however Rails is the most prominent and the one that most books and publications cover.

I can think of some advantages and disadvantages to having your choice of frameworks. Advantage — You can pick the framework that best suits your needs. Disadvantage — You have to take the time to learn enough about each framework to make a choice. Advantage — You can choose to NOT use a framework, thus making your code faster and more effecient. Disadvantage — It’s difficult to combine code from two different projects that are written on two different frameworks.

Ruby on Rails deserves much credit. Anyone who has ever developed a web site knows that there are bits of code you use over and over again. Ruby on Rails, being developed for the purpose of building web sites, makes available some great APIs for getting common tasks done quickly. Ruby Gems are a way of packaging code into a reusable, easily distributed bundle. Gems are great since developers can encapsulate their code easily, this making it easy for other developers to implement. Ruby on Rails is also fully object oriented, whereas PHP is not.

What it all boils down to is that Ruby on Rails is like the Hybrid car of tomorrow. Developers consider ROR to be the sexy new language of the future. Nevermind it’s features or how it works, it’s new. Where does that leave PHP? I suppose it’s place is as the old, outdated language that’s falling by the wayside. Quite the contrary, would one consider unix to be old and outdated? After all, it’s over 30 years old. Anything that old in the computer industry must be old and outdated. But it’s not. In the computer industry, we call unix “mature”.

That’s what PHP is. It’s a mature language. It has a robust set of APIs. It has a broad following. It has plenty of open source backing it. It runs on the majority of servers on the internet. It’s fast. It’s secure. It has all the things you would expect from a mature, robust language.

Delete files older than XX days using PHP

Here’s a chunk of code for deleting old files using PHP code.

$days = 180;
$dir = '/path/to/dir';
	if ($handle = opendir($dir)) {
	while (false !== ($file = readdir($handle))) {
		if ($file[0] == '.' || is_dir($dir.'/'.$file)) {
			continue;
		}
		if ((time() - filemtime($dir.'/'.$file)) > ($days *86400)) {
			unlink($dir.'/'.$file);
		}
	}
	closedir($handle);
}