Take the 2-minute tour ×

In a Magento Shop, I would like to be able to classify products by some Classification mechanism (example: Tag, Category, Related products or somthing else?)

Then I could build a block that will show all classification titles. User can then click and get a page of all products in this classification.



We already use Categories, so using this classification mechanism would generate a list with many unwanted entries. I was thinking using the tag system, but I have not found any references on the web that discusses using tags in this way. Maybe performnace is not good?

Here is a first attempt

// Here is a first attempt - I get all products with Category=4 
// which is a "taggable" category. Then I list all related tags
require_once('app/Mage.php'); //Path to Magento

// Category 4 is called "Category with tags"
$_categoryId = "4";

$_productCollection = Mage::getModel('catalog/category')->load($_categoryId)
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)

    foreach ($_productCollection as $_product):
        $tags= $model->getResourceCollection()
            ->setFlag('relation', true)

        if(isset($tags) && !empty($tags)):
            foreach($tags as $tag):            
                echo $tag->getName(). '<br/>';

Anyone have any code samples for listing tags, or a better way to do this?

share|improve this question
add comment

2 Answers

A quick look in the database convinced me that maybe by-passing Magento's wonderful prodcutivity functions may be in order here...

$sql = "SELECT * FROM tag WHERE status = '1'";
foreach ($connection->fetchAll($sql) as $arr_row) {
    print $arr_row['name'];
share|improve this answer
add comment

Have you tried Layered Navigation? It creates classification mechanism based on product attributes. When entering a category with Layered Navigation enabled, you are presented a list of product attributes that are set to appear there, and their possible values.

To enable Layered Navigation, go to Catalog -> Categories -> Manage Categories. There, select some category, go to Display Settings tab and set Is Anchor to Yes.

To allow or prevent a product attribute from showing in the Layered Navigation list, go to Catalog -> Attributes -> Manage Attributes. There, select an attribute you want and set Use In Layered Navigation option to a desired value.

It may not be exactly what you want, but is worth checking out.

share|improve this answer
add comment

Your Answer


