Fatal error: Call to a member function getUpSellProductCollection() on a non-object
This means your $_product
is not an object but is a null type and you cannot call getUpSellProductCollection()
function on null type.
If you are in product page then your $_product
can be just like this:
$_product = $this->getProduct();
Check Mage_Catalog_Block_Product_View
class
/**
* Retrieve current product model
*
* @return Mage_Catalog_Model_Product
*/
public function getProduct()
{
if (!Mage::registry('product') && $this->getProductId()) {
$product = Mage::getModel('catalog/product')->load($this->getProductId());
Mage::register('product', $product);
}
return Mage::registry('product');
}
Now you can get your up sell product like this:
$upsell_product = $_product->getUpSellProductCollection();