Just mentioning it here since this would be possible too (because getCategoryIds
actually does need the product's Id (pulls it from $product->getId()
) from the whole submitted model only):
$obj = new Varien_Object();
$cats = Mage::getResourceSingleton('catalog/product')->getCategoryIds($obj->setId($productId));
For the record, that's the getCategoryIds
method from Mage_Catalog_Model_Resource_Product
:
/**
* Retrieve product category identifiers
*
* @param Mage_Catalog_Model_Product $product
* @return array
*/
public function getCategoryIds($product)
{
$adapter = $this->_getReadAdapter();
$select = $adapter->select()
->from($this->_productCategoryTable, 'category_id')
->where('product_id = ?', (int)$product->getId());
return $adapter->fetchCol($select);
}