Unhandled Error!

Trying to get property of non-object

Document Product details page.
Document type CMS page POST action code
Line 8
Exception class Cms_ExecutionException

Code Highlight

if (isset($product) && count($product->categories)) {
	$this->page->title = $product->categories[0]->name;
	$this->data['category_url_name'] = $product->categories[0]->get_url_name();
}
 
$this->data['active_page'] = 'shop';
$this->data['product_attributes'] = $product->properties->as_array();
 
foreach ($this->data['product_attributes'] as $attribute) {
	$attribute->value = $attribute->value.' '.$attribute->name;
}
 
if ($weight = $product->weight)
# Document Type
1 Product details page. CMS page POST action code