Remove registry data magento

To remove magento registry data use this code

Mage::unregister('registry_key')

Get array index key

<?php
$color = array(
    'red' => '3',
    'white' => '5',
    'blue' => '3',
    'black' => '10');

while ($color_value = current($color)) {
    
        echo key($color).'<br />';
   
    next($color);
}
?>

Display custom customer field in admin at magento 1.6

To make the new customer attributes saveable in frontend (register and edit) and display admin section execute this code.

eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'your_new_attribute');
$attribute->setData('used_in_forms',   array('customer_account_edit',
                                             'customer_account_create',
                                             'adminhtml_customer'));
$attribute->save();

To make the new customer address attributes saveable in frontend (register and edit) and display admin section execute this

eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer_address', 'your_new_attribute');
$attribute->setData('used_in_forms',   array('customer_register_address',
                                             'ccustomer_address_edit',
                                             'adminhtml_customer_addres'));
$attribute->save();

Easy tab IE9 problem

Easy tab not working on IE9? You can fix this problem by changing

showContent: function(a) {
    var li = $(a.parentNode), ul = $(li.parentNode);
    ul.select('li', 'ol').each(function(el){
      var contents = $(el.id+'_contents');
      if (el==li) {
        el.addClassName('active');
        contents.show();
      } else {
        el.removeClassName('active');
        contents.hide();
      }
    });
  } 

to
showContent: function(a) {
    var li = $(a.parentNode), ul = $(li.parentNode);
    ul.select('li').each(function(el){
      var contents = $(el.id+'_contents');
      if (el==li) {
        el.addClassName('active');
        contents.show();
      } else {
        el.removeClassName('active');
        contents.hide();
      }
    });
  } 

at frontend\default\default\template\easytabs\tabs.phtml

Remove duplicate image from lightbox

Some time lightbox show same image more than one. To avoid duplicate image change function from lightbox.js

uniq();	 to invoke("toJSON").uniq().invoke("evalJSON");

Magento filter attribute

// - array("from"=>$fromValue, "to"=>$toValue)
// - array("like"=>$likeValue)
// - array("neq"=>$notEqualValue)
// - array("in"=>array($inValues))
// - array("nin"=>array($notInValues))
// - array("eq"=>$equal)
// - array("nlike"=>$notlike )
// - array("is"=>$is )
// - array("gt"=>$greaterthan )
// - array("lt"=>$lessthan )
// - array("gteq"=>$greterthanequal )
// - array("lteq"=>$lessthanequal )
// - array("finset"=>$unknown ) 

Display category products with pagination at magento cms page

Add the following XML to your Layout Update XML on your CMS page in:
Admin > CMS > Pages > Your CMS Page Name > Design > Layout Update XML

<reference name="content">
<block type="catalog/product_list" name="home" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>your_category_id</category_id></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>

Design technique of order success page

Some time we face problem when we try to design order success page.Because, we can see success page when we place order. If we refresh page then success page gone away.If we want to see success page again, then we need to place order again. Its is a big problem for developer.

You can easily design order success page. Just comment out some code in successAction (/app/code/core/Mage/Checkout/controllers/OnepageController.php).
Change this code

    public function successAction()
    {
        $session = $this->getOnepage()->getCheckout();
        if (!$session->getLastSuccessQuoteId()) {
            $this->_redirect('checkout/cart');
            return;
        }

        $lastQuoteId = $session->getLastQuoteId();
        $lastOrderId = $session->getLastOrderId();
        $lastRecurringProfiles = $session->getLastRecurringProfileIds();
        if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
            $this->_redirect('checkout/cart');
            return;
        }

        $session->clear();
        $this->loadLayout();
        $this->_initLayoutMessages('checkout/session');
        Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
        $this->renderLayout();
    }

to

    public function successAction()
    {
        /*$session = $this->getOnepage()->getCheckout();
        if (!$session->getLastSuccessQuoteId()) {
            $this->_redirect('checkout/cart');
            return;
        }

        $lastQuoteId = $session->getLastQuoteId();
        $lastOrderId = $session->getLastOrderId();
        $lastRecurringProfiles = $session->getLastRecurringProfileIds();
        if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
            $this->_redirect('checkout/cart');
            return;
        }

        $session->clear();*/

        $this->loadLayout();
        $this->_initLayoutMessages('checkout/session');
        Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
        $this->renderLayout();
    }

Display magento custom variable in phtml file

You can show custom variable in your phtml file.

Mage::getModel('core/variable')->loadByCode('your_variable_code')->getValue('text') ;

Call to a member function extend() on a non-object

I solved this problem using query below.

UPDATE `core_store` SET `store_id` = 0 WHERE `code` like 'admin';
UPDATE `core_website` SET `website_id` = 0 WHERE `code` like 'admin';
UPDATE `customer_group` SET `customer_group_id` = 0 WHERE `customer_group_code` like 'NOT LOGGED IN'; 

Just execute this query to your database.

Follow

Get every new post delivered to your Inbox.