PhpMadman Posted September 9, 2014 Share Posted September 9, 2014 Hello, this is how I currently save my 2 multilang values. Isn't there a better way? Prestashop set the post name to PS_MOD_ORDTPL_INV_invoice_1 or PS_MOD_ORDTPL_INV_invoice_2 And this was the only way I could think of to collect the array of id/values to save. private function updateConfig() { $tpl_names_inv = array(); $tpl_names_des = array(); foreach ($_POST as $opt => $value) { if (strpos($opt, 'PS_MOD_ORDTPL_INV_') !== false) $tpl_names_inv[$opt] = $value; elseif (strpos($opt, 'PS_MOD_ORDTPL_DES_') !== false) $tpl_names_des[$opt] = $value; } $this->setTemplateConfig($tpl_names_inv,'invoice'); $this->setTemplateConfig($tpl_names_des,'delivery-slip'); } private function setTemplateConfig($tpl_names, $type) { $templates = array(); $tplConf = array( 'invoice' => 'PS_MOD_ORDTPL_INV_', 'delivery-slip' => 'PS_MOD_ORDTPL_DES_', ); foreach ($this->getTemplateModels($type) as $tpl) { $templates[$tplConf[$type].$tpl['value']] = array(); foreach ($tpl_names as $conf_tpl => $value) { if (strpos($conf_tpl, $tplConf[$type].$tpl['value'].'_') !== false) { $id_lang = str_replace($tplConf[$type].$tpl['value'].'_', '', $conf_tpl); $templates[$tplConf[$type].$tpl['value']][$id_lang] = $value; } } // save each template with an array of values Configuration::updateValue($tplConf[$type].$tpl['value'], $templates[$tplConf[$type].$tpl['value']]); } } 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