Magento – Get the Current Category

    $currentCategory = Mage::registry('current_category');



Categories: Magento | Leave a comment

How to Obtain Custom Attribute Values in Magento

Categories: Magento | Leave a comment

Contact Form in Magento

As you know, Magento has a built-in contact form that can be used for general contacts. That form isn’t part of any CMS page, you cannot edit some introduction text, you cannot add phone numbers administration, and you cannot see the breadcrumbs. If you wish to edit text in that default contact form, you will need to update front-end files. Luckily, there is an alternative.

Note:You might notice that this is one of our oldest posts. Upon writing we made one error in the code that was never corrected. Now, this post article is updated and we have fully working instructions. Hope this will help.

If you are a developer, editing your contact form HTML is an easy task. You only need to open file:
app/design/frontend/default/[yourtheme]/template/contacts/form.phtml and you will find your way around.

Once there, you will basically edit the layout of this interface.

However, there are cases when you would like to give your client an option to edit some intro text, edit his phone numbers, edit text behind the form, etc. You are probably guessing that it would be nice to be able to embed contact form in some CMS page. No problem.

Go to your CMS> Manage Pages interface
Once there, input your HTML as you normally would on any other page
Once you are happy with HTML part, add this lines:

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

Important note: When you copy/paste the code, it is important to know that WordPress saves the quotes in some weird way, so you should replate the pasted quotes and reenter them.

You will notice that we added xml attribute form_action=”/contacts/index/post”. With it we set form action, and your contact form will work properly. Here is how it looks like. Notice the breadcrumbs.



Categories: Magento | Leave a comment

Adding a new language in Magento

As anything in Magento adding a new language is something that requires a certain procedure which we will explain right now and for future reference.

Follow these easy steps and enjoy your multilingual site:

1. Download the desired translation thru Magento connect via admin.
2. Once installed Go to: System -> Manage Stores -> Create store view. Enter the data and save.
3. Now go to: Configuration -> Current Configuration Scope (Select your language from the dropdown) and on the right side under “Locale options” choose the desired language.
Note: Be sure to clear the cache before trying to use your new language.

That’s it, now when you go to the frontend of the site, you’ll notice a dropdown menu allowing the language switching.



Categories: Magento | Leave a comment

How to Setup SSL in Magento checkout

If you are running a Magento store and taking credit cards , then you should get a SSL certificate to secure your checkout screen. This is how you should do it,
1. Get a SSL certificate and then ask your web host to set it up for your domain.
2. Goto Magento Admin > Configuration > Web .
The {{base_url}} should be changed to
The {{secure_base_url}} should be changed to
3. Switch on the other option below in that page, SECURE URLS ON FRONTEND.
4. Clear your cache.
5. Test on frontend. Add a product to the cart and then try to checkout. It should take you to https .



Categories: Magento | Leave a comment

How To Show Available Quantities in Magento

Magento has the ability to globally manage inventory levels for your online store. A number of client’s business model was to sell inventory that they picked up from a distributor and therefore didn’t need to manage all items. They did have situations where they purchased items by the case and wanted to to show how many items are left back in stock.

To set and show how many items are left in stock, do the following:

Open app/design/frontend/default/template/catalog/product/view.html
Open app/design/frontend/default/template/catalog/product/list.html (for category page)

Add the following code to the page where you want to render the available stock message:


Categories: Magento | Leave a comment

Magento: $_product->getData() VS. $_product->getAttributeName()

here are two main ways of displaying product attributes on the product list, and the product view. Let’s say for this example that our attribute code is ‘customAttribute’. The two ways you’d expect to see this attribute displayed are:

<?php  echo  $_product->  getData('customAttribute') ?>
<?php  echo  $_product->  getAwesomeDude() ?>

Both of these produce the same result. However, they have somewhat significant differences:

In most cases, this is the method you should use. Of the two options, this one is actually faster and more efficient. If you have no need to modify the output, and just want to display the value, use getData(). However, there are attributes that may not work properly with getData() such as the product price. Though I haven’t tested it yet, getData(‘price’) will most likely end up producing different results than getPrice().

You should really only use this method if you are needing to override the method in your block to add functionality to how the data is displayed/formatted. Magento needs to take some additional steps in rendering the data when you use this method, so it is a slightly slower process than displaying data using getData(). So, by using $_product->getAwesomeDude(), I am able to add a function to the product view block for example to modify the data before it is output to the screen:

public function getAttributeName()
  // code to do something with the data
  return $yournewdata;



Categories: Magento | Leave a comment

How To Enable Friendly URLs in Magento

In order to use Magento’s feature for more user and search-engine friendly URLs, you have to login to the Magento’s administration area (usually ** ), click on the *Configuration* button, under the *System* navigation menu, switch to the *Web* page from the sub-navigation panel on the left side of the page.

When the page loads, you will see blue lines, which represents closed settings tablets. Click on the *Search Engines Optimization* tab, and turn on the *Use Web Server Rewrites* (mark as *Yes)*. Click on the *Save Config*button and you are done.

Now you have enabled user-friendly URLs in Magento.


Categories: Magento | Leave a comment

Call to undefined method Mage_Catalog_Helper_Data::canApplyMsrp() in template/checkout/cart/item/default.phtml


Shopping cart page is not loaded or loaded blank or partially blank, the following error message is shown in PHP error log:
PHP Fatal error: Call to undefined method Mage_Catalog_Helper_Data::canApplyMsrp() in template/checkout/cart/item/default.phtml

Mage_Catalog_Helper_Data::canApplyMsrp() method is implemented since Magento 1.6 version, attempts to use this method in earlier Magento versions, like Magento or Magento will result in fatal error.


The proper fix is to prepend any calls to canApplyMsrp() method with if method_exists call.
$canApplyMsrp = Mage::helper(‘catalog’)->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
if (method_exists(Mage::helper(‘catalog’)->canApplyMsrp))
$canApplyMsrp = Mage::helper(‘catalog’)->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);

The exact file name to be patched is shown in PHP error log.
Another fix can be upgrade to Magento 1.6 or later version.


Categories: Magento | Leave a comment

Create a free website or blog at