public function beforeSave()
 {
     $opcoes = $this->getDI()->getShared('ecommerce_options');
     if ($opcoes->produto_detalhes == '0') {
         $this->valor = Produtos::toFloat($_POST['valor']);
         $this->estoque = $_POST['estoque'];
     } else {
         $arr = array();
         if (isset($_POST['detalhes'])) {
             for ($i = 0; $i < count($_POST['detalhes']['valor']); $i++) {
                 foreach ($_POST['detalhes'] as $key => $value) {
                     if ($key == 'valor') {
                         $arr[$i][$key] = Produtos::toFloat($value[$i]);
                     } else {
                         $arr[$i][$key] = $value[$i];
                     }
                 }
                 if (!isset($_POST['detalhes']['detalhe_id'][$i]) || $_POST['detalhes']['detalhe_id'][$i] == '0') {
                     $arr[$i]['detalhe_id'] = (string) new \MongoId();
                 }
             }
             $this->detalhes = $arr;
         }
     }
 }