Jump to content

hk-vierseiter

Members
  • Content count

    6
  • Joined

  • Last visited

Profile Information

  • Real Name
    Daniel K.
  • Gender
    Male
  • Location
    Germany
  • Website
  1. hk-vierseiter

    Easy Populate & Products Attributes

    Hi! I am still having a problem with adding two category fields (category heading title and category description) into the EasyPopulate source code. Until now I have achieved that these two field are properly downloaded, but I am not able to upload any information for the fields. I receive the following sql error: 1062 - Duplicate entry '44-2' for key 1 INSERT INTO categories_description ( categories_id, language_id, categories_description ) VALUES ( 44, '2', 'Kategoriebeschreibung!!! Hoffe, jetzt klappt\'s endlich!' ) The concerned part is found inside this code: // if the categories names are set then try to update them foreach ($languages as $key => $lang){ $baselang_id = $lang['id']; break; } // Überarbeiten!!! Für jede Kategorievariable eine eigene Schleife programmieren, für UPDATE und INSERT if ( isset( $filelayout['v_categories_name_1_' . $baselang_id] ) ){ // start from the highest possible category and work our way down from the parent $v_categories_id = 0; $theparent_id = 0; for ( $categorylevel=EP_MAX_CATEGORIES+1; $categorylevel>0; $categorylevel-- ){ //foreach ($languages as $key => $lang){ $thiscategoryname = $v_categories_name[$categorylevel][$baselang_id]; if ( $thiscategoryname != ''){ // we found a category name in this field, look for database entry $sql = "SELECT cat.categories_id FROM ".TABLE_CATEGORIES." as cat, ".TABLE_CATEGORIES_DESCRIPTION." as des WHERE cat.categories_id = des.categories_id AND des.language_id = " . $lang['id'] . " AND cat.parent_id = " . $theparent_id . " AND des.categories_name like '" . tep_db_input($thiscategoryname) . "'"; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); if ( $row != '' ){ // we have an existing category, update image and date foreach( $row as $item ){ $thiscategoryid = $item; } $query = "UPDATE ".TABLE_CATEGORIES." SET categories_image='".tep_db_input($v_categories_image[$categorylevel])."', last_modified = '".date("Y-m-d H:i:s")."' WHERE categories_id = '".$row['categories_id']."' LIMIT 1"; tep_db_query($query); } else { // Überarbeiten // "$thiscategoryid," instead of "$max_category_id," $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); $max_category_id = $row['max']+1; if (!is_numeric($max_category_id) ){ $max_category_id=1; } // Anstatt "$max_category_id," wurde "$thiscategoryid," eingesetzt $sql = "INSERT INTO ".TABLE_CATEGORIES." ( categories_id, parent_id, categories_image, sort_order, date_added, last_modified ) VALUES ( $thiscategoryid, $theparent_id, '".tep_db_input($v_categories_image[$categorylevel])."', 0, '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."' )"; $result = tep_db_query($sql); foreach ($languages as $key => $lang){ // "$thiscategoryid," instead of "$max_category_id," $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." ( categories_id, language_id, categories_name, categories_heading_title, categories_description ) VALUES ( $thiscategoryid, '".$lang['id']."', '".(!empty($v_categories_name[$categorylevel][$lang['id']])?tep_db_input($v_categories_name[$categorylevel][$lang['id']]):'')."', )"; tep_db_query($sql); } $thiscategoryid = $max_category_id; } // the current catid is the next level's parent $theparent_id = $thiscategoryid; $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later } // } } } // categories_heading_title // if the categories heading titles are set then try to update them foreach ($languages as $key => $lang){ $baselang_id = $lang['id']; break; } // Überarbeiten!!! Für jede Kategorievariable eine eigene Schleife programmieren, für UPDATE und INSERT if ( isset( $filelayout['v_categories_heading_title_1_' . $baselang_id] ) ){ // start from the highest possible category and work our way down from the parent $v_categories_id = 0; $theparent_id = 0; for ( $categorylevel=EP_MAX_CATEGORIES+1; $categorylevel>0; $categorylevel-- ){ //foreach ($languages as $key => $lang){ $thiscategoryheading_title = $v_categories_heading_title[$categorylevel][$baselang_id]; if ( $thiscategoryheading_title != ''){ // we found a category heading title in this field, look for database entry $sql = "SELECT cat.categories_id FROM ".TABLE_CATEGORIES." as cat, ".TABLE_CATEGORIES_DESCRIPTION." as des WHERE cat.categories_id = des.categories_id AND des.language_id = " . $lang['id'] . " AND cat.parent_id = " . $theparent_id . " AND des.categories_heading_title like '" . tep_db_input($thiscategoryheading_title) . "'"; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); if ( $row != '' ){ /* // we have an existing category, update image and date foreach( $row as $item ){ $thiscategoryid = $item; } $query = "UPDATE ".TABLE_CATEGORIES." SET categories_image='".tep_db_input($v_categories_image[$categorylevel])."', last_modified = '".date("Y-m-d H:i:s")."' WHERE categories_id = '".$row['categories_id']."' LIMIT 1"; tep_db_query($query); */ /*} else { // "$thiscategoryid," instead of "$max_category_id," $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); $max_category_id = $row['max']+1; if (!is_numeric($max_category_id) ){ $max_category_id=1; }*/ foreach ($languages as $key => $lang){ // "$thiscategoryid," instead of "$max_category_id," $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." ( categories_id, language_id, categories_heading_title, ) VALUES ( $thiscategoryid, '".$lang['id']."', '".(!empty($v_categories_heading_title[$categorylevel][$lang['id']])?tep_db_input($v_categories_heading_title[$categorylevel][$lang['id']]):'')."' )"; tep_db_query($sql); } $thiscategoryid = $max_category_id; } // the current catid is the next level's parent $theparent_id = $thiscategoryid; $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later } // } } } // categories_description!!!! // if the categories description are set then try to update them foreach ($languages as $key => $lang){ $baselang_id = $lang['id']; break; } // Überarbeiten!!! Für jede Kategorievariable eine eigene Schleife programmieren, für UPDATE und INSERT if ( isset( $filelayout['v_categories_description_1_' . $baselang_id] ) ){ // start from the highest possible category and work our way down from the parent $v_categories_id = 0; $theparent_id = 0; for ( $categorylevel=EP_MAX_CATEGORIES+1; $categorylevel>0; $categorylevel-- ){ //foreach ($languages as $key => $lang){ $thiscategorydescription = $v_categories_description[$categorylevel][$baselang_id]; if ( $thiscategorydescription != ''){ // we found a category description in this field, look for database entry $sql = "SELECT cat.categories_id FROM ".TABLE_CATEGORIES." as cat, ".TABLE_CATEGORIES_DESCRIPTION." as des WHERE cat.categories_id = des.categories_id AND des.language_id = " . $lang['id'] . " AND cat.parent_id = " . $theparent_id . " AND des.categories_description like '" . tep_db_input($thiscategorydescription) . "'"; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); if ( $row != '' ){ /* // we have an existing category, update image and date foreach( $row as $item ){ $thiscategoryid = $item; } $query = "UPDATE ".TABLE_CATEGORIES." SET categories_image='".tep_db_input($v_categories_image[$categorylevel])."', last_modified = '".date("Y-m-d H:i:s")."' WHERE categories_id = '".$row['categories_id']."' LIMIT 1"; tep_db_query($query); } else { // "$thiscategoryid," instead of "$max_category_id," $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); $max_category_id = $row['max']+1; if (!is_numeric($max_category_id) ){ $max_category_id=1; }*/ // Anstatt "$max_category_id," wurde "$thiscategoryid," eingesetzt foreach ($languages as $key => $lang){ // "$thiscategoryid," instead of "$max_category_id," $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." ( categories_id, language_id, categories_description ) VALUES ( $thiscategoryid, '".$lang['id']."', '".(!empty($v_categories_description[$categorylevel][$lang['id']])?tep_db_input($v_categories_description[$categorylevel][$lang['id']]):'')."' )"; tep_db_query($sql); } $thiscategoryid = $max_category_id; } // the current catid is the next level's parent $theparent_id = $thiscategoryid; $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later } // } } } I really tried to fix it myself, but as I am not a php crack, I don't know where I shall start searching for the solution. Maybe somebody here know the way to the solution. The whole easypopulate.php can be found here. Thanks a lot! Daniel
  2. hk-vierseiter

    Easy Populate & Products Attributes

    I tried to solve my problem with the contribution "Category description" myself. With my small PHP and MySql knowledge I had some success, so that there remains only one bug in my code, when I am importing the csv data. Exporting works fine. To the following passage I added the code of the next codebox in order to let EP import the variables "categories_heading_title" and "categories_description". But now I receive the sql error: 1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' '2', INSERT INTO categories_description ( categories_id, language_id, categories_description ) VALUES ( , '2', ' Hier befinden sich Drucker! Von HP über Canon bis Epson!' ) May somebody help me to solve this last error. It is the last obstacle to really start our shop. Thanks! Daniel // if the categories names are set then try to update them foreach ($languages as $key => $lang){ $baselang_id = $lang['id']; break; } if ( isset( $filelayout['v_categories_name_1_' . $baselang_id] ) ){ // start from the highest possible category and work our way down from the parent $v_categories_id = 0; $theparent_id = 0; for ( $categorylevel=EP_MAX_CATEGORIES+1; $categorylevel>0; $categorylevel-- ){ //foreach ($languages as $key => $lang){ $thiscategoryname = $v_categories_name[$categorylevel][$baselang_id]; if ( $thiscategoryname != ''){ // we found a category name in this field, look for database entry $sql = "SELECT cat.categories_id FROM ".TABLE_CATEGORIES." as cat, ".TABLE_CATEGORIES_DESCRIPTION." as des WHERE cat.categories_id = des.categories_id AND des.language_id = " . $lang['id'] . " AND cat.parent_id = " . $theparent_id . " AND des.categories_name like '" . tep_db_input($thiscategoryname) . "'"; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); if ( $row != '' ){ // we have an existing category, update image and date foreach( $row as $item ){ $thiscategoryid = $item; } $query = "UPDATE ".TABLE_CATEGORIES." SET categories_image='".tep_db_input($v_categories_image[$categorylevel])."', last_modified = '".date("Y-m-d H:i:s")."' WHERE categories_id = '".$row['categories_id']."' LIMIT 1"; tep_db_query($query); } else { // to add, we need to put stuff in categories and categories_description $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); $max_category_id = $row['max']+1; if (!is_numeric($max_category_id) ){ $max_category_id=1; } $sql = "INSERT INTO ".TABLE_CATEGORIES." ( categories_id, parent_id, categories_image, sort_order, date_added, last_modified ) VALUES ( $max_category_id, $theparent_id, '".tep_db_input($v_categories_image[$categorylevel])."', 0, '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."' )"; $result = tep_db_query($sql); foreach ($languages as $key => $lang){ $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." ( categories_id, language_id, categories_name ) VALUES ( $max_category_id, '".$lang['id']."', '".(!empty($v_categories_name[$categorylevel][$lang['id']])?tep_db_input($v_categories_name[$categorylevel][$lang['id']]):'')."' )"; tep_db_query($sql); } $thiscategoryid = $max_category_id; } // the current catid is the next level's parent $theparent_id = $thiscategoryid; $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later } // } } } Adding the contribution: // Begin: Adding contribution "Category Description" (Changes by Daniel K.) // adding categories_heading_title (begin) // if the categories heading titles are set then try to update them foreach ($languages as $key => $lang){ $baselang_id = $lang['id']; break; } if ( isset( $filelayout['v_categories_heading_title_1_' . $baselang_id] ) ){ // start from the highest possible category and work our way down from the parent $v_categories_id = 0; $theparent_id = 0; for ( $categorylevel=EP_MAX_CATEGORIES+1; $categorylevel>0; $categorylevel-- ){ //foreach ($languages as $key => $lang){ $thiscategoryheading_title = $v_categories_heading_title[$categorylevel][$baselang_id]; if ( $thiscategoryheading_title != ''){ // we found a category heading title in this field, look for database entry $sql = "SELECT cat.categories_id FROM ".TABLE_CATEGORIES." as cat, ".TABLE_CATEGORIES_DESCRIPTION." as des WHERE cat.categories_id = des.categories_id AND des.language_id = " . $lang['id'] . " AND cat.parent_id = " . $theparent_id . " AND des.categories_heading_title like '" . tep_db_input($thiscategoryheading_title) . "'"; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); if ( $row == '') { // to add, we need to put stuff in categories and categories_description foreach ($languages as $key => $lang){ $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." ( categories_id, language_id, categories_heading_title ) VALUES ( $max_category_id, '".$lang['id']."', '".(!empty($v_categories_heading_title[$categorylevel][$lang['id']])?tep_db_input($v_categories_heading_title[$categorylevel][$lang['id']]):'')."' )"; tep_db_query($sql); } $thiscategoryid = $max_category_id; } // the current catid is the next level's parent $theparent_id = $thiscategoryid; $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later } // } } } // adding categories_description (begin) // if the categories description are set then try to update them foreach ($languages as $key => $lang){ $baselang_id = $lang['id']; break; } if ( isset( $filelayout['v_categories_description_1_' . $baselang_id] ) ){ // start from the highest possible category and work our way down from the parent $v_categories_id = 0; $theparent_id = 0; for ( $categorylevel=EP_MAX_CATEGORIES+1; $categorylevel>0; $categorylevel-- ){ //foreach ($languages as $key => $lang){ $thiscategorydescription = $v_categories_description[$categorylevel][$baselang_id]; if ( $thiscategorydescription != ''){ // we found a category description in this field, look for database entry $sql = "SELECT cat.categories_id FROM ".TABLE_CATEGORIES." as cat, ".TABLE_CATEGORIES_DESCRIPTION." as des WHERE cat.categories_id = des.categories_id AND des.language_id = " . $lang['id'] . " AND cat.parent_id = " . $theparent_id . " AND des.categories_description like '" . tep_db_input($thiscategorydescription) . "'"; $result = tep_db_query($sql); $row = tep_db_fetch_array($result); if ($row == '') { // to add, we need to put stuff in categories and categories_description foreach ($languages as $key => $lang){ $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." ( categories_id, language_id, categories_description ) VALUES ( $max_category_id, '".$lang['id']."', '".(!empty($v_categories_description[$categorylevel][$lang['id']])?tep_db_input($v_categories_description[$categorylevel][$lang['id']]):'')."' )"; tep_db_query($sql); } $thiscategoryid = $max_category_id; } // the current catid is the next level's parent $theparent_id = $thiscategoryid; $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later } // } } } // End: Adding contribution "Category Description" The complete easypopulate.php, you will find here
  3. hk-vierseiter

    [Contribution] Category Descriptions MS2

    Hello! I am new to osCommerce and started to configure the shop. As we switched from another e-commerce platform to osCommerce, we want to keep some of the old one's feature. Until now everything has worked out fine. But today a problem came up which I couldn't solve. We want to use category descriptions which specify the content of the category. So I installed the contribution "category description" which works out fine. Then I installed EP, which was no problem either. Now I wanted to add the field "category_description" to easypopulate.php, so that the content can be exported to the data base. The main difference is that my variable is in the table "category_description" (named "category_description" as well) and not in "product_description". I read the manuals and searched the forum, but I found only answers for adding a field concerning the product not the category. May anybody give me a hint how to add the field "category_description"? You can my easypopulate.php here. But in fact it is the standard configuration. Thanks for your help! Daniel
  4. hk-vierseiter

    [Contribution] Adding new fields to Easy Populate

    Hello! I am new to osCommerce and started to configure the shop. As we switched from another e-commerce platform to osCommerce, we want to keep some of the old one's feature. Until now everything has worked out fine. But today a problem came up which I couldn't solve. We want to use category descriptions which specify the content of the category. So I installed the contribution "category description" which works out fine. Then I installed EP, which was no problem either. Now I wanted to add the field "category_description" to easypopulate.php, so that the content can be exported to the data base. The main difference is that my variable is in the table "category_description" (named "category_description" as well) and not in "product_description". I read the manuals and searched the forum, but I found only answers for adding a field concerning the product not the category. May anybody give me a hint how to add the field "category_description"? You can my easypopulate.php here. But in fact it is the standard configuration. Thanks for your help! Daniel
  5. hk-vierseiter

    Easy Populate & Products Attributes

    Hello! I am new to osCommerce and started to configure the shop. As we switched from another e-commerce platform to osCommerce, we want to keep some of the old one's feature. Until now everything has worked out fine. But today a problem came up which I couldn't solve. We want to use category descriptions which specify the content of the category. So I installed the contribution "category description" which works out fine. Then I installed EP, which was no problem either. Now I wanted to add the field "category_description" to easypopulate.php, so that the content can be exported to the data base. The main difference is that my variable is in the table "category_description" (named "category_description" as well) and not in "product_description". I read the manuals and searched the forum, but I found only answers for adding a field concerning the product not the category. May anybody give me a hint how to add the field "category_description"? You can my easypopulate.php here. But in fact it is the standard configuration. Thanks for your help! Daniel
  6. Hello! I am new to osCommerce and started to configure the shop. As we switched from another e-commerce platform to osCommerce, we want to keep some of the old one's feature. Until now everything has worked out fine. But today a problem came up which I couldn't solve. We want to use category descriptions, so I installed the contribution "category description" which works out fine. Then I installed EP, which was no problem neither. Now I wanted to add the field "category_description" to easypopulate.php, so that the content can be exported to the data base. The main difference is that my variable is in the table "category_description" (named "category_description" as well) and not in "product_description". I read the manuals and searched the forum, but I found only answers for adding a field concerning the product not the category. May anybody give me a hint how to add the field "category_description"? You can my easypopulate.php here. But in fact it is the standard configuration. Thanks for your help! Daniel
×