Unhandled Error!

Trying to get property of non-object

Document shop:list_category_products
Document type CMS partial
Line 3
Exception class Cms_ExecutionException

Code Highlight

      if (post('sorting')) Cms_VisitorPreferences::set('cat_sorting_'.$category->id, post('sorting'));
      $sorting_preferences = Cms_VisitorPreferences::get('cat_sorting_'.$category->id,array('name'));
      $selected_option = $sorting_preferences[0];
<div class="product-list twelve columns">
	<? if (!$category): ?>
		<h2>Category not found</h2>
		<p>We are sorry, the requested category was not found.</p>
	<? else: ?>
	<div id="category_products" class="row">
            $this->render_partial('shop:product_list', array(
# Document Type
2 shop:list_category_products CMS partial
1 Product category page. CMS page