9 Problems You Can Solve With These Magento Tips

Magento is a good open source e-commerce application, but sometimes things don’t seem to go your way. Usually there isn’t a problem with the application but more to do with just not doing things right. Here are some tips that can help you out. This tutorial assumes has been installed and working properly. These instructions are for all three versions of Magento: Community, Professional and Enterprise.

9 Problems You Can Solve With These Magento Tips

1. The Product Name Won’t Display Right

If you’re having trouble displaying the name of the category where your product is stored, go to catalog/product/view.phtml and add this code where you want the category shown.

<?php $categories = $_product->getCategoryIds(); ?>
<?php foreach($categories as $k => $_category_id): ?>
<?php $_category = Mage::getModel(‘catalog/category’)->load($_category_id) ?>
<a href=”<?php echo $_category->getUrl() ?>”><?php echo $_category->getName() ?></a>
<?php endforeach; ?>

2. Missing Layouts

If your templates and layout files aren’t displaying properly you can still see the layouts via the Mage::log() of your controller. By using the code below it will log the layout handles and the update string will be compiled at var/log/layout.log file.

To debug your index.php file use this code:

public function testAction()
// …
//Somewhere within controller action after loadLayout() was called
//The code below logs loaded layout handles to “var/log/layout.log” file
//The code below logs merged layout to “var/log/layout.log” file

3. Safeguard Credit Card Information

Magento by default will include the credit card number in your email. This is hardly secure so you should take steps to remedy it. Begin by opening this file:

Look for these codes:

<?php echo $this->__(’Credit Card Number: xxxx-%s’, $this->htmlEscape($this->getInfo()->getCcLast4())) ?><br/><?php echo $this->__(’Expiration Date: %s/%s’, $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>

Change the code, so it looks like this:

<!–<?php echo $this->__(’Credit Card Number: xxxx-%s’, $this->htmlEscape($this->getInfo()->getCcLast4())) ?><br/><?php echo $this->__(’Expiration Date: %s/%s’, $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>–>

Save the changes, you made.

4. Adding a Contact Form

This tip will allow your clients to a contact form where they can add some text. Magento cannot do this out of the box, but this tip should show you how it is done. Head over to the CMS> Manage Pages interface. Now input your HTML and when you are done, add the following code:

{{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}

5. Hiding the Price

If you want to hide the price and reveal them only to log in visitors, go to

app/design/frontend/default/default/template/catalog/product/view/tierprices.phtml. Add this to the line:

<?php if(Mage::getSingleton(‘customer/session’)->isLoggedIn()): ?>

Then add the following:

<?php if (count($_tierPrices) > 0): ?>

And finally add this code:

<?php endif; ?>

6. How to Put Language Pack in Store View

This isn’t as difficult as it seems as you just need to do the following. First download the language you want and place them in the Magento install directory. Two folders will be placed there, app\locale and app\design\frontend\default\default\locale.
Now head to System > Configuration and click Current Configuration Scope at the left top of the corner.

The Main Store and default Config will not be visible. In this example add the language you chose (in this case French). Go to the French store view and go to the Manage Stores link. Look for the Create Store View link at the right top, type these:

Store: Main Store
Name: French
Code: French
Status: Enabled
Sort order: 0

Save the settings and head over to System > Configuration. Go to the dropdown box “Current Configuration Scope” and look for the French store view. After clicking that link go to the tab Locale and remove the check for “use website” and save it French. Use the same technique for any other language you choose.

7. Put a Facebook Like on a Product

Want to take advantage of Facebook and use it? Use this tip so a user can share the page with their friends.

Here is the code:

<a name=”fb_share” type=”button”></a>
<script src=”http://static.ak.fbcdn.net/connect.php/js/FB.Share” type=”text/javascript”>
<?php elseif($_share == ‘facebook_like’): ?>
<script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″></script><fb:like show_faces=”true” width=”450″></fb:like>
<?php endif; ?>

8. Hide That Empty Shopping Cart

This isn’t as hard as you might think. If you want to hide the shopping cart go to app/design/frontend/default/<your template>/template/checkout/cart/sidebar.phtm and look for the div:

<code><div class=”box base-mini mini-cart”></code>

Put in this php code prior to opening the div tag:

$_cartQty1 = $this->getSummaryCount()
if ($_cartQty1 >0):

Add this piece of code too:


9. Add a Custom Comment at the Product Cart

If you made more than one site for your customers, odds are they will want a comment box for the products. This is very useful since they might have a question about the product they are ordering.

Go to template/checkout/cart.phtml and add the following:
<th><?php echo $this->__(‘Comments’) ?></th>
At template/checkout/cart/item/default.phtml add this column:
<td class=”a-center”>
<textarea name=”cart[<?php echo $_item->getId() ?>][comments]” rows=”3″ cols=”20″><?php echo $_item->getItemcomment() ?>

Author bio: Ed Graham is a veteran Magento extension user, and he has working with the application since its early years at http://www.peexl.com/. His years of experience working with it has allowed him to prepare 10 problems you can solve with these Magento tips and make it easier to use.

Please Note: This is a guest post and I have not tested these codes. Please test these codes on your own risk.

1 thought on “9 Problems You Can Solve With These Magento Tips”

  1. Sue I. Humphrey

    has meaning in other sections of the configuration (see below), but it doesn’t appear to do anything here. However, sections in the Core modules use this tag, so it’s best to follow the convention, even when you’re not sure what it does.

Comments are closed.

Scroll to Top