Magento Themes and Magento Extensions

Magento import complex category

Posted on November 22nd, 2012 | Posted by admin

Magento import complex category

$new_category = $inv->call($sess,”catalog_category.create”, array($par, array(“name”=>$cd['name'],”is_active”=>$cd['is_active'],”available_sort_by”




=>$cd['image'],”meta_title”=>$cd['meta_title'],”meta_keywords”=>$cd['meta_keywords'],”meta_description”=>$cd['meta_description'],”display_mode”=>$cd['display_mode']) ));

Magento Product’s Relative Parent Category Method

Posted on November 6th, 2012 | Posted by admin

In Magento: I want to quickly cover an area that I get asked about at least once a month, and that is “If a product belongs to more than one category.. how do I get the correct parent category while viewing a product through one category or the other?”.

With that said the, the biggest scenario for this need would be to determine the products parent category in order to perform something unique to the product’s page while viewing product’s page through one category or another.

This is a very simple method that assumes you have the product of question loaded up or rather, you are at the product level of your store in order to obtain some information about the products parent categories.

So here we go.

Get Total Number Of Products From Within Any Category

Posted on October 6th, 2012 | Posted by admin

To get the total number of products in a category and show it on the product list page, just add these three lines of code.

This has only been tested on Magento 1.5 but should work on previous versions, let me know in the comments if you have any issues.

In template/catalog/product/list.phtml add these two lines of code where you need the count.

$_productCollection = $this->getLoadedProductCollection();
$count = $_productCollection->getSize();
echo $count;

How to use category to show static pages

Posted on August 18th, 2011 | Posted by admin

Some days ago, I worked on a project which has many URLs linked to static content page. These URLs are shown in main menu. As you know, in main menu are categories. Normally, almost developers add these URLs directly to the phtml file. But I will show you how to do it by another way which is using category .Therefore, you can use each category for one static content page.
First of all, create a static block (instead of static page) by going to CMS > Static Blocks.
After that, going to Catalog > Manage Categories to add new category. To make the category show static block, navigate to ‘Display settings’ tab and select ‘Static block only’ in display mode drop down field.

Magento: Display Only If There Are Products In The Category

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:


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:

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

Hopefully you can find that useful if you need it!

Page 2 of 4«1234»