Minneapolis Project Manager and Web Developer

Category: Magento


Get Individual Product Data in Magento

Magento is built using the Zend PHP Framework, which utilizes the MVC design pattern. An explanation of MVC can be found by a Google search and is beyond the scope of this snippet. For our purposes, one only needs to understand the model or M in MVC.

The model manages the data of the application and can respond to both requests for current information and requests to change information within the database. So if one wants to get Product Data, it makes sense to find the associated Model to request that info. Calling the Product Model in Magento is done with the following syntax:

Mage::getModel(‘catalog/product’);

We can store that new instance of the Product Model and then call various methods on top of it to get the data needed.

$product = Mage::getModel(‘catalog/product’);
$product->load($id);
$sku = $product->getData(‘sku’);
$prod_name = $product->getData(‘name’);

To see a full list … Read More »


Magento Check if on Product Page

I needed to setup a Google Website Optimizer test on one of our store’s product pages, which meant that rather than injecting GWO javascript onto unnecessary pages, it would be more efficient for the end user to only receive this code on product view pages.  The code to quickly check if a product is available and thus on a product page and also avoid using a Singleton or setting up a typical $product object, use:

<?php if (Mage::registry(‘current_product’)) { ?>

A registry, in my limited understanding, is a large collection of objects in which a key is requested and a value returned.


Magento: Remove Cart and Checkout ‘Top Links’

I needed to swap out the default ‘top.links’ that are populated by ‘template/page/top.links.phtml’ and assorted ‘layout/*.xml’ files, respectively.  In most installs, I create a ‘layout/local.xml’ that is overrides existing xml layout files within Magento.  In this particular case, I needed to remove the ‘My Account’, ‘Wishlist’, ‘Cart’ and ‘Checkout’ links.  In addition, I needed to add a link to the ‘Contacts’ page and create the logic to turn back on the ‘Cart’ and ‘Checkout’ links at a later date.

All of this below should go into ‘path/to/magento/app/design/frontend/theme/theme_group/layout/local.xml’

<?xml version=”1.0″?>
<layout version=”0.1.0″>
<default>
<reference name=”root”>
<reference name=”top.links”>
<action method=”removeLinkByUrl”><url helper=”customer/getAccountUrl”/></action>
<remove name=”checkout_cart_link”/><!–Will remove both ‘cart’ and ‘checkout’–>
<block type=”checkout/links” name=”checkout_cart_link_custom”>
Read More »


Magento: Display New Products

14th March

For the shopmyzfa.com website, they needed to display their newest products on their own page. To do this I created a new CMS page entitled, go figure, “New Arrivals”. Using the ‘custom design’ options that Magento affords for each CMS page I added a block to pull all the products that are marked as ‘new’. To mark a product as new one must have set a date for the “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page in the admin. Failure to mark these will keep the block from displaying anything at all.



Moving Magento Sidebar-Cart to Header

27th February

I’ve seen this request on a lot of forums so it would seem to be a fairly common request. Modern eCommerce users typically look for some type of cart notification in the top-right corner. Rather than fight that training, most would seek to encourage it as it, 1) Makes usability that much better and 2) They don’t want to lose clientele just for ‘thinking outside of the box’ design-wise.



Duplicating Magento Catalog Search Anywhere

27th February

Magento is all about taking notes and standing on the shoulders of others. I frequently reuse code that others provide to make development a little faster and smoother. I hope to help out others as they learn by sharing my learning experiences. In this case, a current client needed two search bars on any given page.



Removing Session IDs (SID) in Magento

16th February

When using your Magento store, you may find that an ugly dynamic URL appears with an ending like ‘SID=randomchar’. This is the session ID and is not only aesthetically unpleasant, it could discount your SEO.



Simple Way to Integrate Google Calendar

12th February

Recently a client needed to integrate some kind of calendar into their site that was both easily updated and could be used outside of the site itself. Immediately I thought of Google Calendar, a simple and intuitive organizer of event information.



Speeding up Magento using gZip

One of the drawbacks of Magento is currently its speed if default configuration is used. There are certain ways of making it run faster. The best one is to enable GZip compression by changing .htaccess file a little.


Clearing Cache Manually in Magento

10th February

Magento has a very good cache system that not only creates a faster loading presence after a page has been viewed once, but can keep structural errors from occurring as one is going through and testing difference settings. The problem with this benefit is that, given that the javascript was disabled, the magento admin becomes a useless set of unclickable links as their individual classes and a hrefs are all created using said code. In this case, I needed to refresh the cache to set everything back to normal but it was now unreachable.




From the Blog!

Creating a Video Sitemap in Magento Pt. 1

One of the neat things about Magento is the ability to extend functionality through a pre-defined architecture. This architecture does not really limit...

Cufon not working in Internet Explorer (IE) 9

Received an email from a client stating that their website was no longer working in Internet Explorer 9. Upon looking closer, I realized...

Redirect vs. RedirectMatch .htaccess apache 301

A Magento store is running a CMS page at the /product-selector URL. The request, from marketing, is to redirect a Top-Level Category to...

Magento – Show Sibling Categories using jQuery

For a recent Magento build, we needed to create some quick functionality for user testing. The end result was to show the children...

Using TimThumb.php on WordPress Network

There have been a few headaches in overseeing WordPress Network development, most of which stem from theme developers expecting their work to be used...

Get Data for Magento Category Attribute on Product Page

To retrieve data when in the Category View, /catalog/category/view.phtml, one only needs to use the getCurrentCategory() method and a specifier to the attribute wanted.

getCurrentCategory()...

Different Product Collections in Magento

In building a dynamic video sitemap generator, I need a way to loop through a store’s product collection. As I saw it, if...