Cs-cart Ultimate 3.0.6 Seo Update Bug

OLD

/root/addons/seo/func.php



function fn_seo_update_object($object_data, $object_id, $type, $lang_code, $generate_for_company_ids = array())
{
fn_set_hook('seo_update_objects_pre', $object_data, $object_id, $type, $lang_code, $generate_for_company_ids);
if ((isset($object_data['seo_name']) || !empty($generate_for_company_ids)) && !empty($object_id)) {
$_object_name = '';
$seo_vars = fn_get_seo_vars($type);
if (PRODUCT_TYPE == 'ULTIMATE' && isset($object_data['company_id'])) {
$object_company_id = $object_data['company_id'];
} else {
$object_company_id = '';
}
if (!empty($generate_for_company_ids)) {
$generate_for_company_ids = array_merge($generate_for_company_ids, array($object_company_id));
} else {
$generate_for_company_ids = array($object_company_id);
}
$generate_for_company_ids = array_unique($generate_for_company_ids);
foreach ($generate_for_company_ids as $_company_id) {
$company_name = false;
if (empty($object_data['seo_name'])) {
$object_data['seo_name'] = db_get_field('SELECT name FROM ?:seo_names WHERE object_id = ?i AND company_id = ?i AND type = ?s', $object_id, $_company_id, $type);
$company_name = true;
}
if ($object_company_id == $_company_id) {
if (!empty($object_data['seo_name'])) {
$_object_name = $object_data['seo_name'];
} elseif (!empty($object_data[$seo_vars['description']])) {
$_object_name = $object_data[$seo_vars['description']];
}
} else {
$_object_name = db_get_field('SELECT name FROM ?:seo_names WHERE object_id = ?s AND company_id = ?i AND type = ?s', $object_id, $_company_id, $type);
if (empty($_object_name) && !empty($object_data[$seo_vars['description']])) {
$_object_name = $object_data[$seo_vars['description']];
}
}
fn_create_seo_name($object_id, $type, $_object_name, 0, '', $_company_id, fn_get_corrected_seo_lang_code($lang_code));
if ($company_name) {
unset($object_data['seo_name']);
}
}
}
}






NEW

/root/addons/seo/func.php



fn_set_hook('seo_update_objects_pre', $object_data, $object_id, $type, $lang_code, $generate_for_company_ids);
if ((isset($object_data['seo_name']) || !empty($generate_for_company_ids)) && !empty($object_id)) {
$_object_name = '';
$seo_vars = fn_get_seo_vars($type);
if (PRODUCT_TYPE == 'ULTIMATE' && isset($object_data['company_id'])) {
$object_company_id = $object_data['company_id'];
} else {
$object_company_id = '';
}
if (!empty($generate_for_company_ids)) {
$generate_for_company_ids = array_merge($generate_for_company_ids, array($object_company_id));
} else {
$generate_for_company_ids = array($object_company_id);
}
$generate_for_company_ids = array_unique($generate_for_company_ids);
$seo_name = isset($object_data['seo_name']) ? $object_data['seo_name'] : null;
foreach ($generate_for_company_ids as $_company_id) {
if (!isset($object_data['seo_name']) || (PRODUCT_TYPE == 'ULTIMATE' && !(defined('COMPANY_ID') && COMPANY_ID == $_company_id))) {
if (empty($object_data['seo_name'])) {
$object_data['seo_name'] = db_get_field('SELECT name FROM ?:seo_names WHERE object_id = ?i AND company_id = ?i AND type = ?s AND lang_code = ?s', $object_id, $_company_id, $type, fn_get_corrected_seo_lang_code($lang_code));
}
}
if ($object_company_id == $_company_id) {
if (!empty($object_data['seo_name'])) {
$_object_name = $object_data['seo_name'];
} elseif (!empty($object_data[$seo_vars['description']])) {
$_object_name = $object_data[$seo_vars['description']];
}
} else {
$_object_name = db_get_field('SELECT name FROM ?:seo_names WHERE object_id = ?s AND company_id = ?i AND type = ?s AND lang_code = ?s', $object_id, $_company_id, $type, fn_get_corrected_seo_lang_code($lang_code));
if (empty($_object_name) && !empty($object_data[$seo_vars['description']])) {
$_object_name = $object_data[$seo_vars['description']];
}
}
fn_create_seo_name($object_id, $type, $_object_name, 0, '', $_company_id, fn_get_corrected_seo_lang_code($lang_code));
if ($seo_name === null) {
unset($object_data['seo_name']);
} else {
$object_data['seo_name'] = $seo_name;
}
}
}
}




http://forum.cs-cart.com/tracker/issue-3769-seo-bug/