Pages

Friday, July 5, 2013

Can’t log in Magento Admin

Look for the file:

/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

Arroud the line 100:
call_user_func_array('session_set_cookie_params', $cookieParams);

Add bars to comment the line:
//call_user_func_array('session_set_cookie_params', $cookieParams);

Done!

Now you will be able to login. 

Add links in Magento

Today we’re going to see how to add them to a Static Block or a Page (under your CMS panel).

Example:

If you want to add a link to the page About Us in your footer. How you do that?

If you try this code it will only work for the default lenguage. We need Magento to build a link with our lenguage tag.

<a href="/about-us">About us</a>

What we need is something like http://my_site.com/en/about-us

So we will use Magento shortcodes. You will need to write the page identifier after the direct_url:




<a href="{{store direct_url='about-us'}}">About us</a>

Using the structure above it will build links dinamically with everything it needs in the url.

Extra fee shopping cart price rules in Magento

Under the Promotions tab in your admin panel:



It’s cool but it’s not cool enough. What I wanted to do is to set a surcharge for one payment method. I needed to add a charge in PayaPal method.
So I found the way you can set negative discounts (what means a surcharge) in the cart total price.

Note: we are going to change Magento Core files. Please make a backup of your files before continuing.

1. Go to app/code/core/Mage/Rule/Model/Rule.php

Find the line:

//check if discount amount > 0
if ((int)$this->getDiscountAmount() < 0) {
Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.));
}
Just add some bars // to comment the code:

//check if discount amount > 0
//if ((int)$this->getDiscountAmount() < 0) {
//Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
//}

2. Now go to: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php

Look for:

$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
class=> ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),
And again comment like this:

$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
// ‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),

3. Translate the discount word.

Go to app/locale/es_ES (I’m using the Spainish translation so maybe yours would be en_US)
Find a file called Mage_Sales.csv. Inside look for the word discount you will find something like:

"Discount (%s)","Discount (%s)"
You can change the value in order to show your own text. For example:

"Discount (%s)","Extra Fee (%s)"

Done! Now you’re free to set negative values in the input field:



Fixed amount discount for whole cart

If you select this option the code above will not work entirely. 

How to change currency position in Magento


 I mean it doesn’t crash or something it’s just it doesn’t change the currency position.
Example:
For US Dollars have to be $10,00
But for Euro in Spain we use 10,00€
There is an easy way to change the currency position in the Locale (lenguage) you want.
In my case I wanted to change the € simbol for the Spanish locale on my Magento installation.

1. Go from your root folder to /lib/Zend/Locale/Data

2. Find the lenguage file. In my case es.xml

3. Look for <currencyFormat>

A line just below you will find the <pattern>
Change the side of the weird simbol and leave it like this:

Before
<currencyformatlength>
   <currencyformat>
    <pattern>¤ #,##0.00</pattern>
  </currencyformat>
</currencyformatlength>
After
<currencyformatlength>
   <currencyformat>
    <pattern>#,##0.00 ¤</pattern>
  </currencyformat>
</currencyformatlength>

Now this becomes interesting. Try to refresh the Magento Cache and the browser cache. In my case nothing happened. The change made effect itself an hour after this.
I’m not sure but I think its something about caching those XML files.
Anyway, just be patient until the change comes by itself.

Language pack link in Magento

1. Germany German

http://www.magentocommerce.com/extension/413/magento-community-modules–german-germany-language-pack

Key : magento-community/Locale_Mage_community_de_DE

2. France and French:
http://www.magentocommerce.com/extension/414/magento-community-modules–french-france-language-pack

3.Spanish:

http://www.magentocommerce.com/extension/398/magento-community-modules–spanish-spain-language-pack

key: magento-community/Locale_Mage_community_es_ES

4.Portuguese:
http://www.magentocommerce.com/extension/388/magento-community-modules–portuguese-brazil-language-pack

Key : magento-community/Locale_Mage_community_pt_BR

5.Russian:

http://www.magentocommerce.com/extension/391/magento-community-modules–russian-russia-language-pack

key : magento-community/Locale_Mage_community_ru_RU

6.Japanese:

http://www.magentocommerce.com/extension/415/magento-community-modules–japanese-japan-language-pack

Key: magento-community/Locale_Mage_community_ja_JP

7.Italian:

http://www.magentocommerce.com/extension/377/magento-community-modules–italian-italy-language-pack

Key: magento-community/Locale_Mage_community_it_IT

8.Arabic (Saudi Arabia,In addition to Kuwait,Egyptian Arabic):

http://www.magentocommerce.com/extension/353/magento-community-modules–arabic-saudi-arabia-language-pack

key: magento-community/Locale_Mage_community_ar_SA

9.Traditional Chinese:
http://www.magentocommerce.com/extension/409/magento-community-modules–chinese-traditional-taiwan-language-pack

key: magento-community/Locale_Mage_community_zh_TW

10.Simplified Chinese:

http://www.magentocommerce.com/extension/359/magento-community-modules–chinese-simplified-china-language-pack

How to create and assign customer group in Magento

Customer Groups:-

User can create and view customer groups from Magento admin panel. Admin can view all defined customer groups by clicking on ‘Customers->Customer Groups’. By default there are two customer groups defined in a fresh Magento installation.

    General
    NOT LOGGED IN

New Customer Group creation:-
Admin can create new customer groups from admin panel. Admin just have to click on ‘Customers->Customer Groups’. All defined customer groups will appear in a tabular format. The steps to create a customer group are given below:

    Click on ‘Add New Customer Group’ button.
    New Customer Group section appears.
    Enter new customer group name
    Select the ‘Tax Class’ from Tax Class drop down.
    Click on ‘Save Customer Group’ button.
    New Customer Group will appear on the top of the list along with an auto generated ID.

Customer Group creation

View Customer Groups:-

Admin can view the customer groups assigned to customers by clicking on ‘Customers->Manage Customers’. All customer details will appear in a tabular format. Admin can view the customer group of each and every customer in ‘Group’ column.
View Customer Groups

Assign a customer to a specific Customer Group:-
Admin has the ability to assign a customer to a particular customer group. The required steps are given below:

    Click on ‘Customers->Manage Customers’
    All registered customer details will appear in a tabular format
    Beside each customer detail there is a check box
    Select the check boxes beside customers which will be assigned to a particular customer group

    Click on ‘Actions’ drop down and select the action ‘Assign a customer group’
    Another drop down will appear listing all available customer groups
    Select the desired customer group

    Click on ‘Submit’ button

    All selected customers will be assigned to this new group

Move currency converter to the Header in Magento

If you would like to move the currency switcher from the left column to the header, you can use the following instructions to do so!

Open /app/design/frontend/default/default/layout/page.xml
Locate:

<block type="page/html_header" name="header" as="header">

Change to:

<block type="page/html_header" name="header" as="header">
<block type="directory/currency" name="currency" template="directory/currency.phtml"/>

Open /app/design/frontend/default/default/template/page/html/header.phtml

After:

<?php echo $this->getChildHtml('store_language') ?>

Insert:

<?php echo $this->getChildHtml('currency') ?>

Save, Upload + Clear Cache
Make sure you have imported or manually entered your Currency Rates otherwise the switcher will not appear!
Its as simple as that!!

Remove .html from category or product URL in Magento

Can you help me discover the solution to removing .html from Magento category URL?
How configure magento such that the category url does not have “.html” in the url?
If you want to remove .html from all Magento’s category URL then Follow the below steps

    Go to System -> Config -> Catalog -> Search Engine Optimizations tab
    Delete “.html” from Category URL Suffix.
    Go to System->Index Management
    Reindex “Catalog URL Rewrites”
    Refresh cache

If you want to remove  .html from all Magento’s product URL then steps will same. 
Except 2. Delete “.html” from Product URL Suffix

How to create multiple websites in Magento 1.4

I was getting crazy trying to solve this. Finally I found the solution.

After create the X Websites you need from your Admin section we have to edit a piece of code.

Note: each Website has one unique Store and one unique Store View.

Note2: use short and easy Websites codes, we will need them now.



Sub Domain Method

In your Index.php file (in the root directory of the Magento installation) you have to look for:
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

Then replace the found code for this new one:
// this first line detects the domain / sub domain
switch($_SERVER['HTTP_HOST']) {

case 'store1.domain.com':

/* store1 is the code you wrote in the admin
when created the website */
Mage::run('store1', 'website');

break;

// domain.com (default store)

default:
Mage::run();

break;

}
Sub Directory Method

Using a Sub Directory means more job.

First of all you need to create as much as directories you wanna have.

Example:

    http://mydomain.com/store1
    http://mydomain.com/store2

So following the example you will create 2 directories in the root of your magento installation.

Now you have to copy & paste the index.php and the .htaccess to those folders.

Once that we need to edit the index.php.

Look for:
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

And replace it for:
// this will force to load the Website with the code store1
Mage::run('store1', 'website');

You need to repeat this step to every folder, to every index.php you created before.

Now check out this screenshot to see how to configure the Website:

Done!

Now you know how to create multiples Websites in one Magento Installation. 
 

Script for to remove the cache in Magento

Here, i paste code to remove the cache from the magento. Magento can provide a options to us to remove cache form the admin configuration, but sometimes it not more helpful to us. So expert suggest to remove cache folder..

make one cache-clear.php file into your root folder and paste following code:

 <?php  
 require_once ("app/Mage.php");  
 umask(0);  
 Mage::run();  
 Mage::app()->getCache()->clean();  
 exit("done");  
 ?>  

can call that file with :http://yourdomainname/cache-clear.php

hope this helps :)