Question

I'm trying to join a category with an event.

Here's what I have so far:

<?php
$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$categoryModel = Mage::getModel('catalog/category');
$categories = $categoryModel->getCollection()
                ->addAttributeToSelect(array('name'))
                ->addAttributeToFilter('parent_id', array('eq' => $rootCategoryId))
                ->addAttributeToFilter('is_active', array('eq' => 1));
$categories->joinTable('catalogevent/event', 'entity_id=category_id');

The error I receive is:

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::joinTable()

Any help is greatly appreciated. I get a similar error trying to use joinField and joinAttribute.

Was it helpful?

Solution

Try

$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$categoryModel = Mage::getModel('catalog/category');
                ->getCollection()
                ->addAttributeToSelect(array('name'))
                ->addAttributeToFilter('parent_id', array('eq' => $rootCategoryId))
                ->addAttributeToFilter('is_active', array('eq' => 1));
$categoryModel->getSelect()->join('catalogevent/event', 'entity_id=category_id');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top