January 23, 2014

Yii remove index.php from URL and SEO URL tips


This one is using for removing index.php and also remove site portion from URL.

I am trying to remove index.php from the URL string for so many times. Finally i got some cases in which i want to share with you guys.


Verify mod_rewrite is enabled in your server you can check it to load php.ini file.

Just copied following code and paste into urlManager in main.php
Here's what I put under components file main.php:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
//'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'/'=>'site/index',
'blog'=>'post/index',
'<view:(about)>'=>'site/page',
'contact'=>'site/contact',
'login'=>'site/login',
),
//'urlSuffix'=>'.html',
),

Also,
You can make your own rule to your web page need:
Here, i have changed site/login to login and site/contact to contact.
Also , post/index to blog as you can see in the rules array.

Hope this is one helps you in many ways.





January 09, 2014

Session Variables in Magento


Following are main of the session variables. 

1. First one is about getting information regardng core session data for magento.
Core Session :- Mage::getSingleton(‘core/session’) 

2. Customer session is for getting details associated with the customer data that is currently in session.
You can play with customer session data in shopping cart in the case of one page check out or another kind of. 
Customer Session :- Mage::getSingleton(‘customer/session’);

3 .Admin session gives you information regarding admin session related with admin modules and permisssions.
You have to back up your source code before using this session. This is very important. 
Admin Session :- Mage::getSingleton(‘adminhtml/session’) 

4. Shopping cart session determines that you can get info about various products in shopping cart and customer data. 
Shopping Cart Session :- Mage::getSingleton(‘checkout/session’)->getQuote() 

User defined session variables: 
How to set a session variable in Magento : 
$data = 'Hello heaven welcomes you.'; 
 Mage::getSingleton('core/session')->setMyData($data); 
OR 
Mage::getSingleton('core/session')->setData('my_data', $data); 

How to get a session variable in Magento: 
$string_data = Mage::getSingleton('core/session')->getMyData(); 
OR
$string_data = Mage::getSingleton('core/session')->getData('my_data'); 

var_dump($string_data ); 

January 07, 2014

Magento Admin CMS Pages not showing in admin panel

This might be complicated if you have deleted german, french store etc.
Then or else you will receive error 404 while loading CMS pages in admin panel.

To solve this,

Get Turn on Error log on by renaming file named local.xml.sample to local.xml in errors directory

Now, Run following query in mysql window.

SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

Check your cms_page_store table in database. 
Also, fire this query in window.

DELETE FROM cms_page_store WHERE store_id NOT IN (SELECT store_id FROM core_store)

January 06, 2014

Magento Admin Access Alternate way :: Admin Password Encryption - Decryption

Hello Everyone,

Here the tip for magento admin access.
Go to "app/code/core/Mage/Admin/Model/User.php"

Now, Comes to authenticate method around 325 line no.
You will find this code in this method.
Just comment on it.

/*if ($sensitive && $this->getId() && Mage::helper('core')->validateHash($password, $this->getPassword())) {
                if ($this->getIsActive() != '1') {
                    Mage::throwException(Mage::helper('adminhtml')->__('This account is inactive.'));
                }
                if (!$this->hasAssigned2Role($this->getId())) {
                    Mage::throwException(Mage::helper('adminhtml')->__('Access denied.'));
                }
                $result = true;
           }*/
....................................................................................................

After comment on said condition,

Just write following code before Mage::dispatchEvent('admin_user_authenticate_after', array(); 

$result = true; 
Mage::dispatchEvent('admin_user_authenticate_after', array();

You have access for admin just entering valid username.

Enjoying.

Cheers :)