Fixing infinite redirect loop when ssl enabled in magento admin area

Share
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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public function isCurrentlySecure()
{
if (!empty($_SERVER['HTTPS'])
&& $_SERVER['HTTPS'] != 'off') {
return true;
}
if (Mage::isInstalled()) {
$secureBaseUrl
= Mage::getStoreConfig('web/secure/base_route_url');
if (!$secureBaseUrl) {
return false;
}

Pass data from controller to view in magento

Share
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:

1
2
3
Packname_Modulename_Model_Viewinfo extends Varien_Object{
}

Controller function:

1
2
3
4
5
6
7
public function indexAction()
{
$bla = Mage::getSingleton('Modulename/viewinfo');
$bla->setMsg("Thank You for your visit!");
$this->loadLayout();
$this->renderLayout();
}

Now in your View .phtml file add:

1
2
<?php $blas = Mage::getSingleton('Modulename/viewinfo'); ?>
<?php echo $blas->getMsg(); ?>

Magento – get Attribute Options of the dropdown type attribute

Share
Posted on August 25th, 2014 | Posted by admin

For the attributes 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

Share
Posted on August 23rd, 2014 | Posted by admin

Read Only Access magento 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 \
    app/code/local/Mage/Adminhtml/Controller/Action.php

Getting product image gallery with product id magento

Share
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’;
Mage::app(‘default’);
$_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 15712345»102030...Last »