I have get the current product category id on product details page. I have used some method like :
$_product = Mage::getModel('catalog/product')->load(prodId);
$ids = $_product->getCategoryId();
$cat = Mage::getModel('catalog/product')->setId($ids);
but its not work as i want.
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)
->addViewsCount()
->addCategoryFilter($cat)
->setPageSize($productCount);
but its return some times this error
Fatal error: Call to a member function getId() on a non-object in /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php on line 719
current product category id on product details
means that category from where are goes to product details page?