Password hashing And encryption in Magento

Share
Posted on March 6th, 2015 | Posted by admin

I happened to write this while I was diging how Magento stores password.
well magento stores hashed password separated by a two character salt in db. A sample looks like

353dc2ba6108461cf3468184bdd0e174:QP
split = 353dc2ba6108461cf3468184bdd0e174:QP
magentoPass = split[0];
salt = split[1];
##Authenticate user entered manager.
# is used for concatanation
if( md(5) [split[1]#userenteredpasswd])==split[0])
{
# User Authenticated
}

Now lets understand some cryptography Hashing and encryption.

Password hashing and encryption are two different things. Hashing is one way function while encryption is two way. Reverse encryption (called decryption) is possible but you can not reverse hash and generate your original string back.  You can find another string which has same hash value by brute force methods.

Filtering a Category by Page Layout in Magento

Share
Posted on February 5th, 2015 | Posted by admin

Recently I needed to output categories on the homepage in magento, all these categories had a custom page layout so I thought I may as well filter by that rather than creating a custom category attribute. Here is I how I did that.

public function getCategories() {
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('is_active',array('eq'=>true))
->addAttributeToFilter('page_layout', 'custom_layout')
->load();
return $categories;
}

Add customer in different group during registration in magento

Share
Posted on October 14th, 2014 | Posted by admin

If you want to add customer in different group during registration than follow this instruction.

You need to change in two files.
1) app\design\frontend\[your theme]\default\template\customer\form\register.phtml
add following code in the page

<div>
   <label for="group_id"><?php echo $this->__('Group') ?><span>*</span></label>
   <select name="group_id" id="group_id" title="<?php echo $this->__('Group') ?>" />
   <?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>

Setting A Global Variable In Magento – The GUI Way?

Share
Posted on April 6th, 2013 | Posted by admin

I’ve recently started using  Magento for a client’s webshop, and still need to get to grips with its systems. The webshop should have several links to and also grab info from another domain, where the corporate website is located. I would prefer not to hardcode the domain name or URL but instead define it at some place and use that value in the phtml templates throughout the webshop. This makes it easy to adjust it when we move the site between dev, staging and production URL’s.

we could add a field to the Store’s Config GUI in the backend, similar to the way the {{base_url}} is set. Or maybe I’m thinking the wrong way?

Some Code Samples In Magento

Share
Posted on March 30th, 2013 | Posted by admin

Some Code Samples In Magento

Get CMS Page ID
$pageId = Mage::getBlockSingleton(‘cms/page’)->getPage()->getIdentifier();

How to get product attributes?
<?php echo $_product->getResource()->getAttribute(‘attribute name’)->getFrontend()->getValue($_product) ?>

How to show breadcrumbs in magento?
<?php echo $this->getLayout()->getBlock(“breadcrumbs”)->toHtml(); ?>

How to show Static Blocks?

Page 1 of 3123»