Magento Themes and Magento Extensions

Displaying New Products in Magento with Pagination

Share
Posted on September 13th, 2011 | Posted by admin

Just recently we ran into an issue where we wanted to display all new products added to a specific category in our Magento site with pagination. To make things more complicated, we wanted to display this by using a CMS page. The default functionality that Magento provides for new products just didn’t cut it in our case. We had to come up with something different and I am documenting it here for everyone’s benefit. This method will allow you to add new products to a Magento CMS page and pull up new products for any category you choose, or for the entire site. Whether you want to add new products to your CMS page by category or for the entire site, it’s up to you.

Adding New Products with Built in Magento Tools

First, let’s set the record straight. It is possible to display a list of new products in Magento using a default block. You can do this without any coding changes or modifications to Magento itself. This code will allow you to bring up a list of new products on one of your CMS pages. It is also possible to use this to bring new products up within a template file or on your homepage, though we are not covering that here.

1 {{block type="catalog/product_new" column_count="6" products_count="400" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}

The above code will bring up your 400 newest products in 6 columns. You can change thecolumn_count and products_count variable so that any number of columns or products is shown. You can display all of your newest products by changing the products_count variable to zero. OK, so this is all good, but it’s not what we want. We want to display an entire page of our new products with the pagination toolbar, and we want to display the products with a Magento CMS page. It’s quite simple to accomplish this, and here is how you can do it.

Advanced layout updates for categories and products in Magento

Share
Posted on July 21st, 2011 | Posted by admin

Recently I had a task to modify sorting in only one category of  Magento shop.
What I had to do is “only” to change which attribute will be used for default sorting and I needed to reverse ordering from ascending to descending.
Task seems simple, right?

All you need to do is add/edit your category and in admin panel set your new configuration:

Default Product Listing Sort By:

Adding related products problem

Share
Posted on July 19th, 2011 | Posted by admin

Today I had a problem when I want to add related product to Magento Professional 1.9.0.0., it did not work. After some tracing thrown errors and comparing files with other Magento versions I found missing part. Magento Professional has missing lines of code in Related.php. So, if someone stuck on the same problem, here is the solution!

To correct this issue, do it in Magento way. So create your new module and rewrite that block. Here is the file where you can find these lines of code:
\app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Related.php

Listing products by attribute

Share
Posted on June 23rd, 2011 | Posted by admin

This is step by step tutorial for the beginners that will show you how to list products by attribute.
I will start with functions that Magento already has built-in: New products and Promotional products.
All the instructions below is made from Magento Professional 1.9.0.0

Listing products with attribute New

You can find settings for defining New attribute in Magento administration under Manage products in Products management. For this tutorial I will use CMS page called Homepage as example.
In CMS Page layout -> Layout Update XML is defined template for CMS page by

Magento: Display Only If There Are Products In The Category

Share
Posted on June 3rd, 2011 | Posted by admin

This is a more difficult post to title – but I think that should do it. Here was my need today: We’ve got some navigational links in the header, and there are two categories “Sale Items” and “Internet Only” that should show up as links ONLY if there are products in those categories – otherwise, they shouldn’t be there (no need to have a link to a category with no products in it).

The Solution

There’s a quick’n’easy code line that you can pass in a category id to, and it will return how many products are in that category:

Mage::getModel('catalog/category')->load(198)->getProductCount()

So – I got the category IDs from the admin and I created the following code to check the count – and display the link only if there are products in that category:

<?php
    $sale_count = Mage::getModel('catalog/category')->load(198)->getProductCount();
    if ($sale_count > 0) : ?>
        <li><a href="/sale/">Sale Items</a></li>
<?php
    endif;
    $internet_count = Mage::getModel('catalog/category')->load(200)->getProductCount();
    if ($internet_count > 0) : ?>
        <li><a href="/internet-only/">Internet Only</a></li>
<?php
    endif;
?>

Hopefully you can find that useful if you need it!

Page 3 of 6«12345»...Last »