Magento Themes and Magento Extensions

Automated testing of Magento with Watir

Posted on June 27th, 2011 | Posted by admin

Few months ago I was attending this web conference where among various topic one covered the “Automated testing”. To be honest I never looked into any “automated testing” tools until then. This was the first time I heard about this tool called Watir. Shortly put, Watir (pronounced water), is an open-source (BSD) family of Ruby libraries for automating web browsers.

First thing some of you might notice is that Watir is written in Ruby, and your Magento is written in PHP so how does this relate? Actually it does not. Meaning Watir is not one of those include it in your script then use it tools. Basically it does not interact with your code whatsoever. Consider it as fully independent/separated app that runs desired browser and simulates real user sitting in front of the browser doing all sort of input text filling and form submitting, link clicking etc. Watir also checks results, such as whether expected text appears on the page.

How to extend Magento core controller?

Posted on June 27th, 2011 | Posted by admin

Hi, today I’ll show you how to edit Magento’s core module without messing with core files themselves, or “the right way of doing things”.

First of all, I chose Magento’s Customer module and its Account controller as an example. First, you need to find it in Magento’s Core folder (full path: “app/code/core/Mage/Customer/controllers/AccountController.php“).

First step is to create and place folders in your module that will override Magento’s core controller. On to that part:

  1. First, create this file in same folder structure:app/code/local/Inchoo/Coreextended/controllers/Frontend/Customer/AccountController.php. (of course, you can always replace Inchoo with desired namespace, and Coreextended with some other module name, but you’ll need to edit the rest accordingly).
  2. Then create xml for our module located here:app/code/local/Inchoo/Coreextended/etc/config.xml (same analogy as above applies)
  3. And finally, create this file app/etc/modules/Inchoo_Coreextended.xml.

Handling intensive Magento tasks in the background, simulating AJAX via CRON

Posted on June 27th, 2011 | Posted by admin

For those of a weak hart, please skip this article. Before I start presenting the idea, please note that this is just an idea. So what’s it about? In our everyday Magento development there are numerous examples/tasks where we need to import some data into Magento or programmatically create some entries like products, orders, customers, etc. When dealing with larger scale of things, importing/creating 50000 of products can turn out to be a real challenge. Usually we (the developers) strive to a simplest possible solution, which in this case ideally would be to make simple foreach loop where we would have our code handling product creation in each iteration of the loop. Technically this works, but with extreme PHP/environment configurations only.

Second thing that might come to a mind is AJAX approach, like the one seen on the default Magento store where you initiate your product import. This solution is better than previously mentioned as it eliminates the system ending up “resource-less” . If you catch my point. There is one major drawback with this approach as well. That is, this approach works only while your browser is turned on.

Load XLS files into Magento modules using PHP-ExcelReader class

Posted on June 27th, 2011 | Posted by admin

Recently I had a small problem and it turned out that it wasn’t small as a initially thought. I had to read XLS (Microsoft Excel document) into PHP. After I spent almost 2 hours browsing through internet, I found myself most satisfied with open source project “PHP-ExcelReader class“. It has everything I needed (multiple sheets support and it could read data from both Excel 2000 and 2007). On the other hand, Magento doesn’t support XLS, and I decided to write a small method that you can implement in any Magento class.

So, here it goes:
public function loadXML($path_to_XML)

$include_path = dirname(__FILE__);
$path_to_PHP_ExcelReader = $include_path.”/read_xls/Excel/reader.php”;

require_once $path_to_PHP_ExcelReader;

// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();

How to set multiple stores/websites with one magento installation on different domains

Posted on June 27th, 2011 | Posted by admin

This article will describe quickest way how to use and configure one Magento installation on different domains.
Point here is what do you want to have on that different domains, for example you want to have chosen categories/products on one domain and the other one will be on different language.
First you figure that and then go to configuration.So for each domain you need to create webiste in main Magento admin installation:
System > Manage Stores > Create Website

For Name: you enter name of you desired domain (“”)
For Code: you will enter identifier for that domain (“my_website_com”)

After that you will go to:

Page 4 of 19« First...«23456»10...Last »