vermich Posted July 11, 2013 Share Posted July 11, 2013 (edited) Bonjour à tous, Pour mon site j'ai décidé de placé tout les prix en HT sur lesquels sont ajoutés les taxes puis ma marge. Pour la marge, celle-ci dépendant des groupes j'ai réussi à transformer la réduction par groupe en augmentation par groupe. Pour cela j'ai modifié le fichier AdminGroupController un peu salement et j'appose une réduction négative. protected function validateDiscount($reduction) { if (!Validate::isPrice($reduction) || $reduction > 100 || $reduction < 0) return true; else return true; } Le problème et que maintenant j'ai besoin d'apposé l'augmentation par catégorie, j'ai donc essayer de faire la même chose sur le formulaire d'ajout de réduction par categorie mais impossible de trouver où ça coince je ne comprend pas le cheminement. [PrestaShopException] Property GroupReduction->reduction is not valid at line 837 in file classes/ObjectModel.php 831. 832. $message = $this->validateField($field, $this->$field); 833. if ($message !== true) 834. { 835. if ($die) 836. throw new PrestaShopException($message); 837. return $error_return ? $message : false; 838. } 839. } 840. 841. return true; ObjectModelCore->validateFields - 259. *260. * @return array All object fields261. */262. public function getFields()263. {264. $this->validateFields();265. $fields = $this->formatFields(self::FORMAT_COMMON);266.267. // For retro compatibility268. if (Shop::isTableAssociated($this->def['table']))269. $fields = array_merge($fields, $this->getFieldsShop()); ObjectModelCore->getFields - 459. // Database insertion460. if (isset($this->id) && !Tools::getValue('forceIDs'))461. unset($this->id);462. if (Shop::checkIdShopDefault($this->def['table']))463. $this->id_shop_default = min($id_shop_list);464. if (!$result = ObjectModel::$db->insert($this->def['table'], $this->getFields(), $null_values))465. return false;466.467. // Get object id in database468. $this->id = ObjectModel::$db->Insert_ID();469. ObjectModelCore->add - 44.45. protected static $reduction_cache = array();46.47. public function add($autodate = true, $null_values = false)48. {49. return (parent::add($autodate, $null_values) && $this->_setCache());50. }51.52. public function update($null_values = false)53. {54. return (parent::update($null_values) && $this->_updateCache()); GroupReductionCore->add - 421. * @param bool $autodate422. * @return boolean Insertion result423. */424. public function save($null_values = false, $autodate = true)425. {426. return (int)$this->id > 0 ? $this->update($null_values) : $this->add($autodate, $null_values);427. }428.429. /**430. * Add current object to database431. * ObjectModelCore->save - Argument] 476. $category->addGroupsIfNoExist((int)Tools::getValue('id_group'));477. $group_reduction = new GroupReduction();478. $group_reduction->id_group = (int)Tools::getValue('id_group');479. $group_reduction->reduction = (float)($reduction / 100);480. $group_reduction->id_category = (int)$cat;481. if (!$group_reduction->save())482. $this->errors[] = Tools::displayError('You cannot save group reductions.');483. }484. }485. }486. } AdminGroupsControllerCore->updateCategoryReduction394. {395. if (!$this->validateDiscount(Tools::getValue('reduction')))396. $this->errors[] = Tools::displayError('The discount value is incorrect (must be a percentage).');397. else398. {399. $this->updateCategoryReduction();400. $object = parent::processSave();401. $this->updateRestrictions();402. return $object;403. }404. } AdminGroupsControllerCore->processSave535. {536. // Hook before action537. Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));538. Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));539. // Call process540. $return = $this->{'process'.Tools::toCamelCase($this->action)}();541. // Hook After Action542. Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));543. Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));544.545. return $return; AdminControllerCore->postProcess -Argument] 152. // setMedia MUST be called before postProcess153. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))154. $this->setMedia();155.156. // postProcess handles ajaxProcess157. $this->postProcess();158.159. if (!empty($this->redirect_after))160. $this->redirect();161.162. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) ControllerCore->run - 343. // Execute hook dispatcher344. if (isset($params_hook_action_dispatcher))345. Hook::exec('actionDispatcher', $params_hook_action_dispatcher);346.347. // Running controller348. $controller->run();349. }350. catch (PrestaShopException $e)351. {352. $e->displayMessage();353. } DispatcherCore->dispatch -44. $_POST['controller'] = strtolower($_POST['tab']);45. if (!isset($_REQUEST['controller']) && isset($_REQUEST['tab']))46. $_REQUEST['controller'] = strtolower($_REQUEST['tab']);47.48. // Prepare and trigger admin dispatcher49. Dispatcher::getInstance()->dispatch(); Edited July 11, 2013 by vermich (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now