Boost magento performances managing the two level cache

MagentoIf you are after some improvements on magento “speed”, you will probably interested in why it is so slow, a great explanation about why (a piece at least) magento is slow, is detailed here.

To sum it up, assuming you are using memcached to store the sessions (and I hope you do), here a small snippet to be applied to your app/etc/local.xml file to handle that second level cache:

<config>
 <global>
 [...]
  <cache>
   <backend>memcached</backend>
   <slow_backend>database</slow_backend>
   <fast_backend>memcached</fast_backend>
   <slow_backend_store_data>1</slow_backend_store_data>
   <auto_refresh_fast_cache>0</auto_refresh_fast_cache>
   [...]
  </cache>
 [...]
 </global>
</config>

As it is in the snippet, the second level is stored in the database instead of writing everything in the files as it does by default, using this (after restarting memcached) you will notice a huge boost in speed, you can also disable it by setting the slow_backend_store_data to 0, but that will slow down a lot the website when the cache is empty.

Enjoy!

Magento Dataflow profiles with over 8k products

MagentoIf you are trying to export products from Magento’s Dataflow profile, and you have more than 8000 products, it is common to end up with an error 500 without many information.

To be able to handle that from the web interface without running a profile from the shell, you have to tell your fcgi to be patient!

Here is how to do so:

FcgidBusyTimeout 3600
FcgidIdleTimeout 3600
FcgidProcessLifeTime 7200

Here some more specific informations.

Enjoy!

Export a profile from shell

MagentoI was struggling to run an export profile from the web interface of Magento without having any luck, increasing timeout or memory or anything was not helping at all.
Since I needed that export to be done, with this small script you can do that:


<?php
$profileId = 7; #The ID of the profile from the administration view
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$profile = Mage::getModel('dataflow/profile');
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);
Mage::getSingleton('admin/session')->setUser($userModel);
$profile->load($profileId);
if (!$profile->getId()) {
 Mage::getSingleton('adminhtml/session')->addError('[ERROR] Invalid ID');
}
Mage::register('current_convert_profile', $profile);
$profile->run();
$recordCount = 0;
?>

Enjoy!