[Magento] How to place a product on sale or special in Magento?

When you go around some online shop, sometime you’ll see products with ribbon ‘Sales‘ or will see two price (1 for original price, 1 for new price) and something like that….

So how to do it in magento?

It’s very esay. I’ll explain step by step in this below:

1. Login to the Magento admin.
2. On the top menu go to ‘Catalog > Manage Products.
3. Click the product on the grid to edit.
4. On the left menu, click ‘Prices‘.
5. (If you only have one store skip this step) On the top left, select the appropriate Store from the drop down.
6. Enter the desired Sale price on the field ‘Special Price‘.
7. If applicable, assign a date range using the fields ‘Special Price From Date’ and ‘Special Price To Date‘.
8. Click Save.
9. On the top menu go to ‘System > Index Management‘.
10. Find “Product Prices” from the grid and hit ‘Reindex Data‘.
11. On the top menu go to ‘System > Cache Management‘.
12. Check the ‘Page Cache’ item, make sure the ‘Actions’ dropdown has a value of ‘Refresh‘, and click Submit.

That’s all.

[Magento] How to remove index.php from URLs?

Working with magento, sometime, you can see index.php appear in URLs of your website url. The index.php appears in your URLs because it is the file responsible for processing all requests to the system. In a URL such as http://example.com/index.php/template_group/template, the template_group/template segments are simply information passed to index.php and do not refer to actual files or folders in the server’s filesystem.

Actually, they are not good for SEO, bad for site structure and consistency, and then they’re even worse for a clean URL freak like me.

Let’s clean it…

1. Log-in to your Mangento administration area the go to ‘System -> Configuration -> Web‘.

2. Navigate to Unsecure’ and Secure’ tabs. Make sure the ‘Unsecure‘ and ‘Secure‘-‘Base Url‘ options have your domain name within it, and do not leave the forward slash off the end of the URL. Example: http://tofuandtomato.com/

3. While still on the ‘Web’ page, navigate to the ‘Search Engine Optimisation‘ tab and select ‘Yes‘ underneath the ‘Use Web Server Rewrites‘ option.

4. Navigate to ‘Secure‘ tab again (if not already on it) and select ‘Yes‘ on the ‘Use Secure URLs FrontEnd‘ option.

5. Now go to the root of Magento website folder and use this code for your .htaccess:

* If your Magento store is installed in root(public_html) , use this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

** If your Magento store is installed in a subfolder (public_html/shop), use this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule>

Save the .htaccess and replace the original file (You need backup your original file before replacing).

6. Now go to ‘Cache Management‘ in Administration area to clear Cache.

You are done!

Let’s me know in the comments below if you use this or run into any issues.

[Tofu And Tomato] Magento 1.7 “Database server does not support InnoDB storage engine message”

I’m trying to re-install a cloned Magento 1.7 website on a local server using AMPPS. InnoDB is set as the default engine but it still shows me the message: Database server does not support InnoDB storage engine.

To sort out this issue:

Go To Line 59 of the file app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php

Replace:

public function supportEngine()
{
    $variables  = $this->_getConnection()
        ->fetchPairs('SHOW VARIABLES');
    return (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') ? false : true;
}

With:

public function supportEngine()
{
    $variables  = $this->_getConnection()
        ->fetchPairs('SHOW ENGINES');
    return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'NO');
}

Also see my screenshot:

magento1.7.inodb

[Tofu And Tomato] [Magento Solutions] Fix email not sent

Today, my client at http://www.dubuy.it/ told me that, he had an weird problem with email settings in Magento, he had never receive any sale / order emails after submitting one-page-checkout form.

If the order displays the email as sent and you or your clients are not receiving the email, then the problem is most likely the email settings you have for Magento or the local email server that Magento is using.

I also checked the settings:

  • Admin -> Configuration > Advanced -> System > SMTP Settings and see that you do not have emails disabled.
  • Admin -> Configuration > General > Store Email Addresses and check if you have the email addresses in there correctly. Sometimes email servers would refuse to send email if the senders email is not a proper email address.

However, the settings are correct but emails still were not sent. After digging into the code, I found the issue:

Just been looking into this myself. I’ve followed the code and functions back to this function “public function sendNewOrderEmail()” in:

app/code/core/Mage/Sales/Model/Order.php

starting at line 1270 is the following code:

$emailSentAttributeValue = $this->load($this->getId())->getData('email_sent');
    $this->setEmailSent((bool)$emailSentAttributeValue);
    if ($this->getEmailSent()) {
        return $this;
    }

This is checking the sales_flat_order db table to see if the email has already been sent to the customer and if so just to return, but this does not send the email and should throw an error. So I would say it is a bug somewhere. To fix it so you can resend order/invoice emails etc..

Copy

app/code/core/Mage/Sales/Model/Order.php

to

app/code/local/Mage/Sales/Model/Order.php

and comment out line 1273

if ($this->getEmailSent()) {
            //return $this;
        }

Works like a charm for me. But literally only this second tested it.

magento-fix-email-not-send

[Tofu And Tomato] How to add CSS classes to Magento top links.

Ever wonder or ever hit your head on the wall what bloody template file controls the site link, footer link in Magento and how to add a class to it? That’s right, it’s thepage/template/links.phtml.

The template file generates ‘first’ and ‘last’ class in li tag, but sometimes we need more styling in each individual link list and we want to add a class either in li or anchor tag without hacking the core file or extend a class in Magento core, how do we do that?

The answer is in the xml file

magento-top-links

LET’S HAVE A LOOK AT MY CODE:Screen Shot 2014-10-18 at 11.38.48 AM

[Tofu And Tomato] Magento – How to add another language to your store

I currently have two sites under development that are going to take advantage of multiple languages.

One will have a second store view in French and another will have a second store view in Spanish.

The fist step is to change the default store view name to English. Login into admin and go to the System>Manage Stores section.
Click on Store View Name for your default store. Change the store name to English. Then save.

Next step is to create the second store view, which will be Spanish.
Click on Create Store View button at top.
Enter your information for the Spanish store per image below:

new-spanish-store

Click on Save Store View and you should have a new Spanish store view.
On the front end, you will now see that there is a store switcher in the header area.

switcher

Now, we have two stores, one english and one spanish.
But as you can see, it’s not all working as it should.
If you go to the home page in the Spanish Store, we will get a 404.
You can fix that by assigning the home page to All Store Views, per below.

home

You will also need to go to Catalog>Manage Products and select all your products, then update attributes.
Then go to websites section, per below, and add product to website.

update-products

You should now see all your products showing in categories, regardless of what store view you are in.
We will cover products later.

If you take a quick look at your Spanish view store, you will notice that it’s not really in Spanish, it’s still in English.
That’s because you haven’t given Magento any translations for your Spanish store. That’s next.

Go to Magento’s Translations Page.
Search for your language pack then click on it to go to the pack’s download page.
You are now ready to download the Spanish pack, see below.

translations

Save the es_MX folder to your desktop, and upload to your server in the app>locale folder.See below.

locale

Now that you have installed the Spanish language page, it’s time to tell Magento about it.
Go to System> Config> General tab, then click on Locale Options tab.
In top left, select Current Configuration Scope, and select Spanish. See below.

config Now that Magento knows about our Spanish language pack, it should be serving translated files in the front end.
Let’s see…

translated

Finally, we will talk about product translations.
If you want to have Spanish in a product, for example, you will need to go to Catalog>Manage Products.
Select your product, then select Spanish store view in top left.
Add your Spanish translations to short description, for example, by unchecking ‘Use Default Value’ and then pasting in your Spanish translation. See below.

short-desc

Here is result of that translation on front end…

short-desc-tl

I know that’s alot of steps, but it’s really amazing what we have just done.

We now have a multi-language store, serving different visitors, in their own tongue.