Home » Archive

Articles tagged with: Magento Tips

Magento Customization, Magento Guide »

[15 Oct 2009 | One Comment | ]

Adding an Adwords tracking code to order confirmation page in Magento is relatively easy task. One that can be handled under an hour or so if you choose to implement it the proper way. Here is how.
Modify the “app/design/frontend/default/my_custom_theme/layout/checkout.xml” file. Look for section

<checkout_onepage_success>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
<reference name="content">
<block name="checkout.success" template="checkout/success.phtml" type="checkout/onepage_success" />
</reference>
</checkout_onepage_success>

And turn it into

<checkout_onepage_success>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
<reference name="content">
<block name="checkout.success" template="checkout/success.phtml" type="checkout/onepage_success" />
</reference>
<reference name="before_body_end">
<block name="google_adwords_tracking" template="checkout/google_adwords_tracking.phtml" type="core/template" />
</reference>
</checkout_onepage_success>

Create the “app/design/frontend/default/my_custom_theme/template/checkout/google_adwords_tracking.phtml” file and copy-paste the the Adwords tracking JavaScript code into it.

This code relies on

< ?php echo $this?>getChildHtml(’before_body_end’) ?>

block call from footer of each …

Magento Customization »

[15 Oct 2009 | No Comment | ]

This post describes how Magento navigation works. I hope it will help you.
The begining of all is in template file: “category/navigation/top.phtml”

<ul id="nav">
< ?php
foreach ($this->getStoreCategories() as $_category): ?>
< ?php
echo $this->drawItem($_category);
?>
< ?php endforeach ?>
</ul>

There we call the method from class Mage_Catalog_Block_Navigation $this->getStoreCategories(). This method returns the array $_nodes from object Varien_Data_Tree_Node_Collection.
This array contains objects of Varien_Data_Tree_Node.
Every node is object of Varien_Data_Tree_Node and it is extension from Varien_Object.
Example 1:
If we wish to see how much categories we have, we can do it with method showed below:

< ?php
echo $this->getStoreCategories()->count();
?>

We will get only number …

Magento Guide »

[14 Oct 2009 | One Comment | ]

There are two unused product list blocks in Magento which can be very useful if you push a few buttons, edit few layouts ..

1. Promotion
Block located in app\code\core\Mage\Catalog\Block\Product\List\Promotion.php
This is basically built in featured product functionality. It reacts to “promotion” attribute which needs to be created, so let’s click
Catalog->Attributes->Manage Attributes->Create New Attribute
Attribute Code: promotion
Scope: Global
Catalog Input Type for Store Owner: Yes/No

Label: Promotion (second tab)
Other params can be left alone, but it’s up to you of course. I also labeled it Promotion just for this article.
Now we need to add …

Magento Customization, Magento Guide »

[14 Oct 2009 | No Comment | ]

In order to speed things up with building admin sections under System > Configuration area in Magento I wrote a little blank extension. Hopefully its a step or two beyond “Hello world” level. I named the extension “CoolDash”, short from CoolDashboard. Name holds no special meaning, just something I popped out of my head. First thing you might notice when you open config.xmls and system.xml is the attribute naming. I intentionally used names like “somecooldashmodel2″. I found it extremely difficult, error prone and annoying to get around in scenarios where …

Magento Customization, Magento Guide »

[12 Oct 2009 | No Comment | ]

Simple : ) -Ok, lets get down to business. This one is really, really simple, but powerful. In all it greatness Magento lacks the good content management solution (CMS features). Lot of people are heading down the road of integrating the WordPress and Magento. Probably everyone in web development has heard about WordPress. Personaly I like them, from Joomla, Drupal, Wordpress… But there is that little something that makes WordPress far more loving in the eyes of the client. Not to start a flame here, lets get back to the …

Magento Customization, Magento Guide »

[7 Oct 2009 | One Comment | ]

Ever wanted to “just send the email” using the built in email features in Magento? Ever hit the wall trying to do something with Magento? OK, I know the answer to the other one, just had to ask . Anyhow, sending the emails with Magento turned out to be a process of “just” a few hours of tracing Magento code.
I cant wait for smart comments like, “few hours, huh its so easy…”. Yea, thats the beauty of Magento… few hours of bashing your head against the wall while you …

Magento Customization, Magento Guide »

[6 Oct 2009 | No Comment | ]

Due to the “complexity” of Magento’s xml files, developers can waste great amount of time on “unnecessary” things.
When I say “complexity” I say it with purpose. XML files are not so complex by them selves, but due to extreme lack of documentation and changes Magento pumps in every new “major” release, people are lost among things that should really be sideways. Anyway, in this little article I will show you how to create basic, startup structure for your module to get it shown under Magento Admin main top menu.
As you …

Magento Guide »

[6 Oct 2009 | No Comment | ]

As many things in Magento, removing product comparison is not available thru the admin interface. Thus, leaving us with the only option of getting down and dirty with theme files editing.

This guide is pretty straightforward and is based on the Magento ver. 1.3.1.1
Before beginning of this procedure please Go to: System-> Cache Management and disable cache. You can turn it on after you’re done.
Step 1 – reports.xml
Open: app/design/frontend/deafult/Your Theme name/layout/reports.xml and delete the following lines:

<block type="reports/product_compared" before="right.permanent.callout" name="right.reports.product.compared" template="reports/product_compared.phtml" />

<pre><block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /></pre>

Step 2 – catalog.xml
Open app/design/frontend/deafult/Your …

Magento Guide »

[5 Oct 2009 | No Comment | ]

Adding a new tab under onepage checkout in Magento might seem as incredibly easy task. right?! Well, it’s not. If you want to do it properly, you gonna have to do some work. Took me few hours to get this one running. Attached are screenshots for you to see final result.

Here is the module itself Inchoo_Heared4us.
Few words about module. It uses built in Admin theme module from a coworker Ivan Weiler. If you have this Admin theme module installer already please disable it, since its built into this Heared4us module. …

Magento Guide »

[5 Oct 2009 | No Comment | ]

There are few different ways one can achieve this kind of functionality. Normally in Magento you would do it like a real, “independent”, module (extension) thus loosing at least two ours to make a few lines of code work.
The simplest way to add this kind of feature to your product view page is to open the view.phtml file under the app/design/frontend/default/custom/template/catalog/product/ folder.
And add the following code where you sish to show your “Tweet this” link:

<a title="Send this page to Twitter!" href="http://twitter.com/home?status=Check out the <?php echo $this->htmlEscape($_product->getName()) ?> at < ?php …