public function collection_update($id = null)
 {
     if (is_null($id)) {
         redirect(get_url('plugin/ecommerce/collection'));
     }
     if (!($collection = Collection::findById($id))) {
         Flash::set('error', __('Collection not found!'));
         redirect(get_url('plugin/ecommerce/collection'));
     }
     if (get_request_method() == 'POST') {
         $collection_id = $this->_collection_save($id, 'collection', 'Collection');
         //insert log
         $this->_insert_log('Collection <a href="' . get_url('plugin/ecommerce/collection_update/' . $collection_id) . '">' . $_POST['collection']['title'] . '</a> was updated.');
         redirect(get_url('plugin/ecommerce/collection'));
     }
     //get products
     global $__FROG_CONN__;
     $sql = 'select pc.id, pc.collection_id, pc.product_id, p.title, pc.position from ecommerce_collection c inner join ecommerce_product_collection pc on c.id = pc.collection_id inner join ecommerce_product p on p.id = pc.product_id where c.id = ' . $id . ' order by pc.position;';
     $stmt = $__FROG_CONN__->prepare($sql);
     $stmt->execute();
     $products = $stmt->fetchAll();
     $this->display('ecommerce/views/collections/update', array('action' => 'update', 'collection' => $collection, 'products' => $products));
 }