Example #1
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists() || empty($this->productCode)) {
         $o = new Product();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
         $position = (string) $this->position;
         $l = 6 - strlen($position);
         $st = "";
         for ($i = 0; $i < $l; $i++) {
             $st .= "0";
         }
         $position = $st . $position;
     }
     return parent::save($object, $related_field);
 }