Home Archive

Articles tagged with: Magento Tips

24 Sep 24 Sep 2009 1Comment

How many people were disappointed to install Magento’s test data and find out that the home page “Best sellers” was just pain HTML placed into the CMS home page? I certainly was one of those people. That’s why I decided to create a Bestseller Module that was dynamic and harnessed the power of Magento’s built in features. This post shows you the code and gives and explanation of what is happening.
For those of you impatient to get to the code, here it is:

<?php
//bestseller module – grabs from all products, returns …

Read More

 
24 Sep 24 Sep 2009 Comments Off

Many developers are familiar with the MVC (Model View Controller) design pattern that is seemingly ubiquitous throughout web frameworks. Looking through the code in Magento, however, we see many other components besides the M’s the V’s and the C’s.
Each module  (a “module” meaning the separate directories within the “app/code/core/Mage” directory that comprise of Magento’s different functional areas) contains the usual Controller and Model. You’ll see that within each module, there are no Views (more on this later). You’ll also see extra tidbits, such as “helper” , “etc” and “sql”. These …

Read More

 
24 Sep 24 Sep 2009 Comments Off

If like many of the Magento store owners you find that some of the built-in features are not useful to you or to your customers you can always disable them via the admin interface buy disabling their respective modules.
Wishlist is not one of them.
To remove all of the traces of the wishlist functionality you need to do the following:
1. Go to the Admin interface (select the appropriate scope) and under System -> Configuration -> Customers -> Whishlist select “No” under the “Enabled” in the General options.
This will remove all …

Read More

 
23 Sep 23 Sep 2009 1Comment

Hi All -
Finally time for a new post! (Something I’m surprised I haven’t covered yet).
This post will inform you on how to run Magento code outside of Magento. All you need is to have access to Magento’s ‘app/Mage.php‘ file.
This will be handy code for a few things:

Integration with 3rd party items – shared sessions, or just shared themes
Ajax calls – although not the preferred solutions for Ajax calls, it is a quick and easy one

To expand on these ideas a bit more:
Integration:
-You can use this code to output HTML that …

Read More

 
21 Sep 21 Sep 2009 1Comment

Recently I have been working on a custom checkout page for one of our clients in Sweden. I had some trouble figuring out how to send default Magento order email with all of the order info. After an hour or so of studying Magento core code, here is the solution on how to send email after successful order has been made.

< ?php
$order = new Mage_Sales_Model_Order();
$incrementId = Mage::getSingleton(’checkout/session’)->getLastRealOrderId();

$order->loadByIncrementId($incrementId);

try
{
$order->sendNewOrderEmail();
} catch (Exception $ex) {  }
?>

Not sure how useful this alone will be for you, so I’ll throw a little advice along the way. …

Read More

 
16 Sep 16 Sep 2009 Comments Off

For those of you who are into kinky stuff I made a simple, more of a proof of concept, application that sits in Widnows taskbar and shows the order info in balloon popup. Took me little more than half of hour to get this working. Almost forgot how great C# is
Magento has this great feature, rss feed for orders. You can access it via link http://myshopsite/rss/order/new. It requires authentication, so you need to provide Magento user and pass to access this link. Idea I wanted to play around …

Read More

 
16 Sep 16 Sep 2009 Comments Off

One of the coolest things in Magento is a form validation, and the way how it’s done. Magento uses Prototype library (which, personlay, I’m not a big fan of) to manage form validation. All you need to do when writing custom form is to assign a valid class names to your input fields. Here is an example of how your custom form might look in order to get use of automatic form validation.

<form name="<em><strong>my-custom-form</strong>" id="my-custom-form" action="" method="post">

<label for="firstname">< ?php echo $this->__(’First name’) ?> <span>*</span></label>
<input id="firstname" name="firstname" />

<label for="lastname">< ?php echo …

Read More

 
15 Sep 15 Sep 2009 Comments Off

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.
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 …

Read More

 
14 Sep 14 Sep 2009 Comments Off

One of my recent articles was on the subject of sorting “On Sale” product in Magento. The following is a cleaner and more advanced look at how—with few tricks and smart moves—you can reuse existing Magento code and modify it to suit your needs.
Product can be “on sale” in two ways:
1. when an item has a special price assigned to it on the individual level, or
2. when a special promotion “covers” the item
It is important to remember that you don’t have to set up the special price on each product …

Read More

 
12 Sep 12 Sep 2009 Comments Off

You can add items to magento’s system log and exception log in your code. This is very handy for pin-pointing coding errors / problems. Developing for Magento is often hard, especially since it’s not always possibly to have error reporting on (and even when it is on, its hard to find exactly what’s wrong!).
Here’s an example of it’s use:
1) Turn on your logging: Admin > Configuration > Developer > Log Settings > Enabled = Yes
2) Example code snippet where you might find this useful:

<?php
$response = curl_exec($ch); //just an example of …

Read More