Saturday 10 August 2013

How to Configure Magento for Development / Debug Mode

1. Disable Cache
System > Cache Management > Select All [check-boxes] > Actions = Disable > Submit
2. Re-Index All
System > Index Management > Select All [check-boxes] > Actions = Reindex Data > Submit
3. Disable Compilation
System > Tools > Compilation > Disable
Note: By default compilation mode is disabled. So just check if the Compiler Status is Enabled or not.
4. Turn on Error Reporting
a> Open index.php and un-comment the following line
1
#ini_set('display_errors', 1);
b> Open .htaccess and add the following line at the end
1
SetEnv MAGE_IS_DEVELOPER_MODE "true"
5. Turn on Logging
System > Configuration > Advanced > Developer > Log Settings > Enabled => Yes
6. Configuring Mangeto Error Page
rename errors/local.xml.sample to errors/local.xml

7. Install ‘Easy Template Path Hints’
Install Easy Template Path Hints for turning on/off the template path hints for frontend and backend easily & securely.

Friday 9 August 2013

Custom search engine friendly (SEF) URL In Magento.


Custom SEF helper method

class <Namespace>_<Module>_Helper_Data extends Mage_Core_Helper_Abstract
{
function custom_sef_url($id_path, $request_path, $target_path, $store_id ="0", $is_system=false){
$isrewrite = Mage::getModel('core/url_rewrite')->load($id_path,id_path);
    if($isrewrite->url_rewrite_id !=""){
      throw new Exception("Your Id path must be unique, given id path already in use !");
    }
      $rewrite = Mage::getModel('core/url_rewrite');
      $rewrite->setStoreId($store_id)
        ->setIdPath($id_path)
        ->setRequestPath($request_path)
        ->setTargetPath($target_path)
        ->setIsSystem($is_system)
        ->save();       
return;
}
}

Where should I call Custom SEF helper method?

Normally we need to create the custom URL once the new item is created, so we need to call this method in your “saveAction()” function after saving process. Let’s take FAQ items as example.

public function saveAction()
{

// .... faq saving process

try{
  $id_path = "faq/".$id;  // Id path must be unique
  $request_path = "fag/".$fag_title;
  $target_path  = "fag/index/index/id/".$id;

   Mage::helper('<module>')-&gt;custom_sef_url($id_path, $request_path, $target_path);
}
catch (Exception $e) {

 Mage::getSingleton('adminhtml/session')-&gt;addError($e-&gt;getMessage());

}

}