Fixing infinite redirect loop when ssl enabled in magento admin area

Posted on August 27th, 2014 | Posted by admin

You can encounter infinite redirect loop when turning on ssl in magento admin area.

The thing is in this model app/code/core/Mage/Core/Model/Store.php:

public function isCurrentlySecure()
if (!empty($_SERVER['HTTPS'])
&& $_SERVER['HTTPS'] != 'off') {
return true;
if (Mage::isInstalled()) {
= Mage::getStoreConfig('web/secure/base_route_url');
if (!$secureBaseUrl) {
return false;

Pass data from controller to view in magento

Posted on August 26th, 2014 | Posted by admin

t’s may be very easy for Zend framework user But, I find some magento developer fighting to pass data from controller to view.
In magento you have to create a empty model(if your mod don’t have a varient object model) which extends to varient object. Magento use magic getter magic setter so you can pass value by setAnyname() and getAnyname() thus functions will be auto defines by Zend like many other framework do.

Model file:

get Attribute Options of the dropdown type attribute in Magento

Posted on August 25th, 2014 | Posted by admin

For the attributes attribute in Magento which have a frontend type “Select” we need to define options that on the product page converted into a dropdown. For example attribute color may have options Red, Green, Blue etc. which are defined in the admin area.

We can easily collect all the defined options for any attribute.

This code will return all options of attribute “color”

// use your own attribute code here
$attribute_code = "color";
$attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code);
$options = $attribute_details->getSource()->getAllOptions(false);
Foreach($options as $option){
	// print_r($option) and find all the elements
	echo $option["value"];
	echo $option["label"];

Magento admin backend Read Only Access Role

Posted on August 23rd, 2014 | Posted by admin

Read Only Access magento admin backend admin users might come handy if you don’t want your employees to mess around with your website content.

Here is how to setup Read Only Access users:

  • create backend permission role with the name ReadOnlyAccess
  • create backend user and assign ReadOnlyAccess role to it
  • overwrite Mage_Adminhtml_Controller_Action class preDispatch function to filter denied actions:
    cp app/code/core/Mage/Adminhtml/Controller/Action.php \

Getting product image gallery with product id magento

Posted on August 20th, 2014 | Posted by admin

If this is a file out of the magento core api you must include this at the top

require_once ‘./app/Mage.php’;
$_helper = Mage::helper(‘catalog/output’);

since we are finding the product with id rather than using the this it is frequent to use the above in the file

Getting the product id with get method

$_productId = $_GET["id"];; // product ID 10 is an actual product, and used here for a test
Create the product object with the identified id
Page 1 of 212»