Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi folks,

I set up a new store and added two languages. After adding some categories and products I decided to delete one of this languages and add a completely different one. I went to admin to update my products and categories, but the category name, product name and product description were not saved for this added language. This is bad luck, because you can not add anything except in default language.

The problem is in the admin/categories.php:

Look for:

		  } elseif ($action == 'update_category') {
		tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  }

After the above code add this:

		  //BOF is categorie name given, when no insert it
	  if ($action == 'update_category'){
	  #check db
	  $check_cat_name = tep_db_query("select * from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  $num_cat_name = tep_db_num_rows($check_cat_name);
	  #when no entry is found, insert new categorie name in correct language
	  if(!$num_cat_name){
		$insert_sql_data = array('categories_id' => $categories_id,
								 'language_id' => $languages[$i]['id']);
		$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
	  #perform db entry		  
	  tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
	   }
	  }
	  //EOF

Look for:

			} elseif ($action == 'update_product') {
		  tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
		}

After the above code add this:

		  //BOF is categorie name given, when no insert it
	  if ($action == 'update_product'){
	  #check db
	  $check_pd = tep_db_query("select * from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  $num_pd = tep_db_num_rows($check_pd);
	  #when no entry is found, insert new products description in correct language
	  if(!$num_pd){
		  $insert_sql_data = array('products_id' => $products_id,
								   'language_id' => $language_id);

		$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
	  #perform db entry		  
	  tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
	   }
	  }
	  //EOF

 

Now you can add as many languages as you want in a running system.

This code is also for people interesting which uses easy populate with 2 languages: I am using version 2.74 and when I add new categories it only creates it for one language. Now it is handy to edit the categories via oscommerce admin than with phpmyadmin. :thumbsup:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...