function getProductHome() { $productHome = new producthome(); $productHome->where_related_product('active', 1); $productHome->where('productcat_id', $this->id); $productHome->order_by('position', 'asc'); $productHome->get_iterated($this->numProductHomepage); return $productHome; }
function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new producthome(); $o->where("productcat_id", $this->productcat_id); $o->select_max('position'); $o->get(); if (count($o->all) != 0) { $max = $o->position + 1; $this->position = $max; } else { $this->postion = 1; } $o->clear(); $o = new producthome(); $o->where('productcat_id', $this->productcat_id); $o->where('product_id', $this->product_id); $o->get(); if ($o->exists()) { return true; } } return parent::save($object, $related_field); }
function deleteProductHome($id) { $productHome = new producthome($id); $productHome->delete(); }