Easy management of Magento scheduled tasks: Magento Cron Scheduler

Today one of my colleagues shared a really nice extension with me: Magento Cron Scheduler.

This extension lets you easily list and manage all the scheduled tasks in Magento, it also shows the the processes that will run in the following hours and the ones that were already executed.

  • Available tasks. Shows the list of all the crons defined in Magento, showing also the periodicity and the model they call.
Available Tasks - Magento Cron Scheduler

Available Tasks – Magento Cron Scheduler

  • Scheduled tasks. Show the list of the tasks that will be executed during the next hours and also the tasks that have already been executed. It also includes the messages in case the already launched tasks return a message.
Scheduled tasks - Magento Cron Scheduler

Scheduled tasks – Magento Cron Scheduler

  • Timeline. Nice feature! It shows a timeline diagram showing which tasks will be executed during the day.
Timeline - Magento Cron Scheduler

Timeline – Magento Cron Scheduler



Script to execute upgrade actions without flushing the cache in Magento

When having many different servers I have faced more than once issues related to module installation/upgrades. Here you have a quick script that upgrades all modules from terminal:

require_once "../app/Mage.php";

$begin = microtime(true);
Mage::log("Upgrade Begin-".$begin);


$end = microtime(true);
Mage::log("Upgrade End-".$end);
Mage::log("Duree : ".($end - $begin));

Search AutoComplete and Suggestions extension for Magento

I just wanted to share this awesome [Free] Magento extension that modifies the quick search box by:

  • Directly showing results (instead of related searches)
  • Showing search suggestions

Search Autocomplete for Magento

Search Autocomplete for Magento

Magento default quick search shows related searches as you type. From my point of view, this is not relevant at all. On the other hand, having results directly under the search box… that’s totally worth it. 

Of course, you’ll need to apply some styles to the results box.

[Off-Magento] Solving the Warning: ssh2_scp_send(): Failure creating remote file: Invalid ACK response from remote error

Recently I had to use ssh2 through php in order to send files from one server to another. I don’t know why, I was getting a error that was not actually very common on the Internet. My code was:

$connection = ssh2_connect($host, $port);
ssh2_scp_send($connection, $path_origin, $path_target, 0644);

The connection was correctly placed, but when trying to copy the file, I got:

Warning: ssh2_scp_send(): Failure creating remote file: Invalid ACK response from remote

After looking for the solution, I finally found something [not really related to this issue]. There are other ways of copying files through ssh using php, and that’s what I did. Here is the workaround I found:

$srcFile = '/path_to_origin_file';
$dstFile = '/path_to_server_file';

$host = 'ssh_host';
$port = '22';
$username = 'ssh_user';
$password = 'ssh_password';

// Create connection the the remote host
$conn = ssh2_connect($host, $port);
ssh2_auth_password($conn, $username, $password);

// Create SFTP session
$sftp = ssh2_sftp($conn);

$sftpStream = fopen('ssh2.sftp://'.$sftp.$dstFile, 'w');

try {

    if (!$sftpStream) {
        throw new Exception("Could not open remote file: $dstFile");

    $data_to_send = file_get_contents($srcFile);

    if ($data_to_send === false) {
        throw new Exception("Could not open local file: $srcFile.");

    if (fwrite($sftpStream, $data_to_send) === false) {
        throw new Exception("Could not send data from file: $srcFile.");


} catch (Exception $e) {
    error_log('Exception: ' . $e->getMessage());

Filter product collection by multiple categories in Magento

During the past week I’ve dealed with a very weird and stressing thing with my colleagues: filtering a product collection by multiple categories in Magento.

  • Filter by only 1 category

Magento offers a type of filter that can be used directly from the collection:

$_category = Mage::getModel('catalog/category')->load($category_id);

  • Filter by 2 or more categories

This is a completely different story. It’s very important to proceed correctly in order to avoid errors of the type:
[blockquote]Item (Mage_Catalog_Model_Product) with the same id already exist[/blockquote]

Proceed in the following way:

1. Call your collection and filter by the attributes you want to filter (all but the category one). For example:

$collection= Mage::getResourceModel('catalog/product_collection')
           ->addFieldToFilter('type_id', array('eq' => 'configurable'));

2. After doing this, you can apply your multiple category filter as follows:

$categories_to_filter = array('3', '4', '5');
$ctf = array();

foreach ($categories_to_filter as $k => $cat) {
     $ctf[]['finset'] = $cat;

$collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')

Important: do it in this order if you don’t want to face weird Magento issues.

Best way of disabling the Region select for addresses in Magento

Region select is not perfect in Magento. For example, for UK, there are missing counties, probably due how official they are or maybe just because Magento didn’t take the correct database.

One way or another, region field is not considered one of the required fields for most sellers when integrating orders on their ERP.

What is the best and cleanest way for disabling this select box? From my point of view, this is the best way:

Launch this mysql query on your database:

TRUNCATE TABLE directory_country_region;
  • You don’t need code changes
  • You can easily recover this table
  • This will affect throught all the web. No more select menus for region.

If you’re not convinced, you might check other options.

Magento EE 1.13 & EE 1.8

Magento EE 1.13 is finally out (last version was released in December. The focus of this version has been performance, especially regarding indexing. These are good news, as our experience with indexing problems and performance during the last months has been really bad.

Reindex Section in Magento

Reindex Section in Magento

Magento CE 1.8 will follow soon, something completely necessary, as the last version was released in July 2012 (that means nearly 8 months without any updates, not even security updates)

The most important changes are the following ones. You can also see the complete list on the Magento Website:

  • Reindexing (Enterprise Edition only):
    • Most indexing processes now run only to update products, categories, URL redirects, and so on that have changed—eliminating the need for manual full reindexing
    • Your Magento web store is not locked at any point during reindexing
    • Reindexing is now a background process.
  • Caching (Enterprise Edition only):
    • Full page caching now invalidates only pages that are affected by product or category changes
    • Improved cache adapter for single-host systems
    • Additional option of using Redis NoSQL for cache and session storage in multi-host deployments (recommended for new deployments)
  • EE customers also get detailed performance and tuning guidelines geared toward enterprise installations
  • Sales, Value Added, and Fixed Product Tax calculations (Magento CE and EE):
  • Checkout performance (Magento CE and EE) achieved by:
    • Eliminating unnecessary calls to gift wrapping when loading the Shipping Method checkout step
    • Eliminating unnecessary RSS cache cleanups when RSS functionality is disabled
    • Eliminating unnecessary calls to the translation module when sending new order e-mails if the current locale is the same as the locale set in Magento
    • Improving the overall checkout process performance by loading the information for the current checkout step only
    • Improving the overall checkout process performance by loading the progress information for the current checkout step only

Programmatically set product position in a category in Magento

Today I had to reorder products in a category. Basically, our client wanted to put the products with special price at the end. After trying to do this with the category model in Magento, I finally run into the Category Api. It worked like a charm, even though it works kind of slow. Here you have the solution (with an example):

$categories = Mage::getModel('catalog/category')->getCollection();
$new_order = 300;
foreach($categories as $category){
    $cat_api = new Mage_Catalog_Model_Category_Api;
    $products = $category->getProductCollection();

    foreach ($products as $product){
       $cat_api->assignProduct($category->getId(), $product->getId(), $new_order);

Passing arguments to a Magento Shell script

Using Magento Api to create shell scripts seems to be easy, but there are too many things to take into account to get the most of it. In this case, I want to explain how to pass an argument from the command line when executing a magento shell script.

You have to call the script passing the argument title and argument value:

php shellscript.php --argument_title argument_value

Then, on the script code, you can retrieve this value using from your class using:


Magento development blog