Articles tagged with: Magento Tutorials
One of the problems working under the hood of the Magento CMS is determining the context of $this. If you are about to do any advanced stuff with your template, besides layout changes, you need to get familiar with Magento’s objects (classes).
Let’s have a look at the /app/design/frontend/default/default/template/catalog/product/view.phtml file. If you open this file and execute var_dump($this) your browser will return empty page after a short period of delay. By page I mean on the product view page; the one you see when you click on Magetno product. Experienced users …
Improving Magento performance is at the top of the list for most professional Magento developers. There’s no doubt that enhancing the speed at which Magento performs can only be good for business.
One of the most important enhancements you can make to your Magento installation is to properly configure your MySQL database server.
A proper MySQL configuration requires a low level understanding of your underlying hardware and, primarily, the memory (RAM) available.
There is one specific MySQL configuration parameter above all others that will produce significant performance improvements and takes very little understanding …
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. You just need to uncomment part of the code. In my case, the speed increase was exactly 235%.
Find the following lines in your Magento .htaccess file and replace them with the following code.
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 …
Magento main menu is construed based on the hierarchy like,
Root Category → Category → Sub-Category
We will customise the menu to show the Products of a category/su-bcategory along with its hierarchy in dropdown menu as seen below.
This is a good feature if you have less products in a website.
In order to implement the above structure, we need to modify the navigation.php file of drawItem() function like below. The navigation.php is available in the following location,
app/code/core/Mage/Catalog/Block/Navigation.php
The code is,
<code>Public function drawItem($category, $level=0, $last=false){
$html = ”;
if (!$category->getIsActive()) {
return $html;
}
$children = $category->getChildren();
$hasChildren = $children …
Just some code for custom category menu navigation. I’m a bit short on time so, no fancy walk trough. All you need to make this show on your page is to call it inside layout file like
<block type=”core/template” template=”surgeworks/customcatnav.php” />
Filename: customcatnav.php.
<?php
//Get store id
$storeId = Mage::app()->getStore()->getId();
//Get category model
$_category = Mage::getModel(’catalog/category’)->setStoreId($storeId);
$_categoryCollection = $_category->getCollection();
$_categoryCollectionIds = $_categoryCollection->getAllIds();
//Remove root category from array
unset($_categoryCollectionIds[0], $_categoryCollectionIds[1]);
?>
<div class=”content”>
<?php
$o = null;
$o .= ‘<dl>’;
foreach ($_categoryCollectionIds as $catId)
{
$_category = $_category->load($catId);
if($_category->getLevel() == 2)
{
$catChildren = $_category->getChildren();
if(!empty($catChildren))
{
$o .= ‘<dt>’.$_category->getName().’</dt>’;
$categoryChildren = explode(”,”, $catChildren);
foreach ($categoryChildren as $categoryChildId)
{
/* @var $_childCategory Mage_Catalog_Model_Category */
$_childCategory = $_category = Mage::getModel(’catalog/category’)->setStoreId($storeId)->load($categoryChildId);
$o .= ‘<dd>’;
$o …
Recently, I just finished coding out a website for a client in Magento. You can view the site at www.3graces.com, it was a full switch from some old legacy asp shopping cart to Magento. Im really happy with the way things turned out and the client is too, Magento just has so many wonderful features built-in.
One feature that I found wasn’t built in was a way to display each sub-category with an image, and its name on a landing page. Magento has a nice feature which allows you to assign …
Here are 3 quick solutions to try if you do not see your Magento store categories after a fresh install of Magento or an upgrade to the latest version. I wanted to post this because I just recently helped install Magento for someone and experienced this. The installation version was the latest Magento version, 1.2.1.2 and product categories did not show up on the frontend after they were added in the administration interface.
The top 3 solutions to this in my experience are:
The categories not added as sub-categories of the Default, …
This is quite a common want, so I thought I would put together a quick tutorial with some ideas and pointers. My main goal will be to give you a starting point for building a static block and PHTML file that can be applied to top level categories to dynamically create a block with of all the subcategories.
The first thing to do is create a new static block (CMS → Static Blocks), lets call it ‘Dynamic Landing Pages’. Within the content paste this:
{{block type=”catalog/navigation” name=”catalog.category” template=”catalog/category/list.phtml”}}
If you’ve not seen …
Magento Vertical Menu using Peter Hamilton’s code
In one of our premium Magento themes we implemented a vertical category menu with the code adapted from this thread. It’s quite easy to implement and to make it even easier for others, we decided to write a step by step tutorial.
Add a new block type in “catalog.xml” file
Create a new phtml file and name it “leftnav.phtml”, place it inside catalog/navigation
Edit CSS
Add a new block type in “catalog.xml” file
Here we presume you want to have the vertical category menu shows up on every page, …
I have a few custom blocks I’ve written / copied and tweaked from various posts on Magento’s forums. I noticed they are pretty universal in how they grab, filter and return a product collection to be used in various template files (.phtml files). The blocks below should all work from List.phtml (app\design\frontend\default\default\template\catalog\product\list.phtml).
These are Block files and are most appropriately used within the Catalog/Product area. (See my post on creating a custom module – these files won’t be overwriting any other class but can …

Recent Comments