/** * AddAttributes * Add a list of attributes in a group * @param integer $groupid * @param array $attributes * @return boolean */ public static function AddAttributes($groupid, array $attributes) { if (!empty($attributes)) { foreach ($attributes as $attributeID) { $attrs = new ProductsAttributesGroupsIndexes(); $attrs->attribute_id = $attributeID; $attrs->group_id = $groupid; $attrs->save(); } return true; } return false; }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/productsattributesgroups/process"); $request = $this->getRequest(); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributesgroups/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributesgroups/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); try { // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('list', 'productsattributesgroups', 'admin'); } if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('group_id'); // Set the new values if (is_numeric($id)) { $this->productsattributesgroups = $this->productsattributesgroups->find($id); } // Get the values posted $params = $form->getValues(); $this->productsattributesgroups->name = $params['name']; $this->productsattributesgroups->code = Shineisp_Commons_UrlRewrites::format($params['name']); $this->productsattributesgroups->isrecurring = $params['isrecurring'] ? 1 : 0; $this->productsattributesgroups->iscomparable = $params['iscomparable'] ? 1 : 0; $this->productsattributesgroups->isp_id = Shineisp_Registry::get('ISP')->isp_id; $this->productsattributesgroups->save(); $id = is_numeric($id) ? $id : $this->productsattributesgroups->getIncremented(); // Delete the old group ProductsAttributesGroupsIndexes::deleteAllAttributes($id); if (!empty($params['attributes'])) { ProductsAttributesGroupsIndexes::AddAttributes($id, $params['attributes']); } $this->_helper->redirector('edit', 'productsattributesgroups', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success')); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Hosting Plan Feature details"); $this->view->description = $this->translator->translate("Here you can fix the hosting plan feature details."); return $this->render('applicantform'); } } catch (Exception $e) { $this->_helper->redirector('edit', 'productsattributesgroups', 'admin', array('id' => $id, 'mex' => $e->getMessage(), 'status' => 'danger')); } }