/* = */
public function getDescripProduct($product_id) {
$seodata = array();$sql = "SELECT language_id, seo_title, seo_h1, seo_h2, seo_h3, meta_description, meta_keyword, description, alt_image, title_image, meta_seo_data FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'";$query = $this->db->query($sql);
if(count($query->rows)){
$_SESSION['current_meta_seo_data'] = array();
}else{
unset($_SESSION['current_meta_seo_data']);
}
foreach ($query->rows as $result) {
$seodata[$result['language_id']] = array('seo_title' => $result['seo_title'],'seo_h1' => $result['seo_h1'],'seo_h2' => $result['seo_h2'],'seo_h3' => $result['seo_h3'], 'alt_image'=> $result['alt_image'], 'title_image'=> $result['title_image']);
$_SESSION['current_meta_seo_data'][$result['language_id']] = $result;
}return $seodata;}
public function setDescripProduct($product_id, $data = array(), $oc_data = array()){
if(!count($data)){$this->load->model('localisation/language');$languages = $this->model_localisation_language->getLanguages();$data = array();foreach ($languages as $l_code => $l_val) {$data[$l_val['language_id']] = array('seo_title'=> '','seo_h1'=> '','seo_h2'=> '','seo_h3'=> '');}}
foreach($data as $language_id => $val){
$val['meta_description'] = $oc_data[$language_id]['meta_description'];
$val['meta_keyword'] = $oc_data[$language_id]['meta_keyword'];
$val['description'] = $oc_data[$language_id]['description'];
$query = $this->db->query("SELECT product_id FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "' AND language_id = '". (int)$language_id ."';");
if(count($query->rows)){
$meta_seo_data = $this->getSeoMetaData($val, $language_id);
$meta_seo_data = "meta_seo_data = '" . $meta_seo_data . "'";
$sql = "UPDATE " . DB_PREFIX . "product_description SET seo_title = '". $this->db->escape($val['seo_title']) ."', seo_h1 = '". $this->db->escape($val['seo_h1']) ."', seo_h2 = '". $this->db->escape($val['seo_h2']) ."', seo_h3 = '". $this->db->escape($val['seo_h3']) ."', alt_image = '". $this->db->escape($val['alt_image']) ."', title_image = '". $this->db->escape($val['title_image']) ."', ". $meta_seo_data ." WHERE product_id = '" . (int)$product_id . "' AND language_id = '". (int)$language_id ."'";}else{$sql = "INSERT INTO " . DB_PREFIX . "product_description SET product_id = '". (int)$product_id ."', seo_h1 = '". $this->db->escape($val['seo_h1']) ."', seo_h2 = '". $this->db->escape($val['seo_h2']) ."', seo_h3 = '". $this->db->escape($val['seo_h3']) ."', seo_title = '". $this->db->escape($val['seo_title']) ."', alt_image = '". $this->db->escape($val['alt_image']) ."', title_image = '". $this->db->escape($val['title_image']) ."';";}$this->db->query($sql);}
unset($_SESSION['current_meta_seo_data']);
}
private function getSeoMetaData($new_data, $language_id){
if(!isset($_SESSION['current_meta_seo_data'][$language_id])) return '';
$meta_seo_data = json_decode($_SESSION['current_meta_seo_data'][$language_id]['meta_seo_data'], true);
$old_data = $_SESSION['current_meta_seo_data'][$language_id];
if($meta_seo_data && is_array($meta_seo_data)){
foreach($old_data as $key => $val){
if(isset($new_data[$key]) AND $this->db->escape($new_data[$key]) != $val AND isset($meta_seo_data[$key])){
if($val !='' AND $meta_seo_data[$key] == 'ag' AND $new_data[$key] != ''){
$meta_seo_data[$key] = 'et'; // edited
}elseif($val !='' AND $meta_seo_data[$key] == 'et' AND $new_data[$key] != ''){
/*empty*/
}else{
unset($meta_seo_data[$key]);
}
}elseif(isset($new_data[$key]) AND $this->db->escape($new_data[$key]) == '' AND isset($meta_seo_data[$key])){
unset($meta_seo_data[$key]);
}
}
}else{
$meta_seo_data = '';
}
return !$meta_seo_data ? "" : $this->db->escape(json_encode($meta_seo_data));
}
/* = */