public function remove() { StoreProductImage::removeImagesForProduct($this); StoreProductOptionGroup::removeOptionGroupsForProduct($this); StoreProductOptionItem::removeOptionItemsForProduct($this); StoreProductFile::removeFilesForProduct($this); StoreProductGroup::removeGroupsForProduct($this); StoreProductLocation::removeLocationsForProduct($this); StoreProductUserGroup::removeUserGroupsForProduct($this); StoreProductVariation::removeVariationsForProduct($this); $em = Database::get()->getEntityManager(); $em->remove($this); $em->flush(); $page = Page::getByID($this->cID); if (is_object($page)) { $page->delete(); } }
public function save() { $data = $this->post(); if ($data['pID']) { $this->edit($data['pID']); } else { $this->add(); } if ($this->isPost()) { $errors = $this->validate($data); $this->error = null; //clear errors $this->error = $errors; if (!$errors->has()) { //save the product $product = StoreProduct::saveProduct($data); //save product attributes $aks = StoreProductKey::getList(); foreach ($aks as $uak) { $uak->saveAttributeForm($product); } //save images StoreProductImage::addImagesForProduct($data, $product); //save product groups StoreProductGroup::addGroupsForProduct($data, $product); //save product user groups StoreProductUserGroup::addUserGroupsForProduct($data, $product); //save product options StoreProductOption::addProductOptions($data, $product); //save files StoreProductFile::addFilesForProduct($data, $product); //save category locations StoreProductLocation::addLocationsForProduct($data, $product); if ($data['pID']) { $this->redirect('/dashboard/store/products/', 'updated'); } else { $this->redirect('/dashboard/store/products/', 'success'); } } //if no errors } //if post }