Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing Manufacturer Tables, Fields & Headings?


iwik

Recommended Posts

Posted

Hi there,

 

I'm setting up an online bookstore, and there have been several posts dotted around these forums which have helped in my setup considerably, but the biggest question I have at the moment is this:

 

I've gone through and changed all "manufacturer" to "author" through the box headings and mentionings on the page (ie. in the advanced search and so forth) but I want to change the actual MySQL table heading to be Author (so the URL's mention an author_ID rather than a manufacturer_ID) and the fields within that table to become Author_info and Author_image, to reflect the fact that is is indeed a bookstore. A manufacturer is not needed at all because the authors are the people who count, and whose information is needed.

 

Now, I'm aware that I'll have to go through and change all the general sql references to the table/fields but the one thing I'm confused about is when it comes to such things as

define('TABLE_HEADING_MANUFACTURER', '...')

 

Should I then alter these to be TABLE_HEADING_AUTHOR throughout my php pages because of the change, and do I have to specify somewhere in my config file about the table name change?

 

I've backed up my current database and files so I can tinker with ease, knowing that I can't screw it up too much (I hope!).

Posted

Wanted to do the same thing, so this is the method I used.

 

It may be a nasty way of doing it, but it works.

 

1. BACKUP!BACKUP!BACKUP!BACKUP!BACKUP!

2. Backup Database via admin to local file, say....catalog/admin/backups/ then mkdir temp and mv file there.

3. cd ....backups/temp

4. Run

perl -pi -e 's/manufacturer/*newitem/g' *.*

where *newitem is author or artists etc

this command will work for files in the current directory.

5. cd to /catalog

6. Run

find . -type f -exec perl -spi -e 's/manufacturer/*newitem/g' {} \;

where *newitem is author or artists etc

this command will work for files in the current directory AND sub directories.

7. Restore Database to original location.

8. Enjoy searching and viewing by author etc....

 

I also ran, and may be a little redundant but I wanted to cover all avenues, I repeated steps 4 and 6 using Manufacturer and MANUFACTURER with *Newitem and *NEWITEM to get all spelling, as the command is Case Sensitive.

 

After that, just roam around your store and check for any inconsistencies, especially heading labels etc, they can be a little stubborn.

 

M

  • 2 weeks later...
  • 2 weeks later...
  • 3 weeks later...
  • 3 weeks later...
Posted

hi mantarogue,

 

Thanks so much for that! Sorry I didn't reply sooner but I got busy with other stuff and the store got put on the backburner.

 

I attempted your way of doing it, and it seems I managed to completely break my store.. oops (I guess it's a good thing it's on a test site rather than a proper one eh?).

 

Though, I managed to run the perl statements there with no hassle, how exactly did you restore the database? :blink:

 

I backed it up using the admin tools and ran the perl statement on it in it's backups/temp folder, but how do I then 'restore' it - therefore implementing the new changes? I can't get into the admin area to hit the resore button. Once I've "perl'd" the catalog folder I can't access the storefront or admin at all as I get an error about it the database (the non-altered one - the one that should be overwritten) being able to join with the tep something something.. I closed the window before I noted exactly what it was.. sorry.

 

 

If you could help me with this it'd be much appreciated.

Posted

Ok, so.

 

After running that little perl statement there, I noticed that nothing would work because every instance of author or AUTHOR or whatever in my php files happened to have an asterix in front of it (eg *author).

 

So, I then went through and changed everything manually (doing a search-and-destroy in editpad) changing manufacturer to author and MANUFACTURER to AUTHOR etc.. etc..

 

I also manually went through my database in phpadmin and changed all instances of manufacturer to author.

 

My site runs fine now except for one or two little hiccups which I can't quite figure out:

 

1. For some reason it won't bring across the author's (ex-manufacturers) names into the dropdown menu in the manufacturers (authors) box, where before it would have "Please Select, Canon, GT Interactive etc.." (I've created another subdomain on my webspace and am using the default install to play with this so I can then alter it all and add in my new bits to the original store when it is all working ok). Instead I have "Please Select" and then a list of "..." where their names should be. However, when you select any of the dots, it will display the product listing for that particular author, and will even show up their images and what have you for their product listing.

All I've done is changed all instances of manufacturer to author (in all cases) within boxes/manufacturers.php and have renamed it to authors.php. The column_left.php file does call the authors.php file.

 

2. When I go into my Admin section and select authors (to either add, delete or edit) instead of showing "Date Added: 10/20/2004" in the side bar where the author's information is, it will show "TEXT_DATE_ADDED 10/13/2004" and all the other headings like that on that page will display as the 'define' variable, rather than the content of it. As with the previous problem, all I did was change all instances of manufacturer to author within admin/manufacturers.php and re-save it as authors.php.

 

All other areas are fine though. And when I add a product it will show the drop-down list of the authors to select from.

I've already gone through and double-checked my admin/includes/languages/english.php file to make sure it's not still calling anything related to manufacturers and to make sure that the TEST_DATE_ADDED is defined, but why wouldn't the authors.php be referring to the english.php file for that information?

 

 

 

Can anyone think of why this would be acting up and how I can correct it? I've already gone through and double-checked my admin/includes/languages/english.php and includes/languages/english.php files to make sure they're not still calling anything related to manufacturers.

 

Anything you could possibly think of would be great.

 

Thanks a bunch for all the help these forums have provided. They're tops!

Posted

I thought I might just pop in a couple of screenshots so you can all understand where my predicament lies.

 

The drop down author weirdness:

authordropdown.jpg

 

The admin TABLE_HEADER weirdness:

adminscreenshot.jpg

Posted

Well, it appears as though my admin problem has sorted itself out. It's now showing the right bits of text as the headers.

 

My drop down is still an issue though. I thought I might also put some code in so you can see what I have there.

 

It should be exactly the same as what the normal includes/boxes/manufacturers.php file is, except with all instances of manufacturers being changed to authors.

 

If you can spot anything, please let me know :blink: I think it must have something to do with either getting the author's name into the array, or the MAX_DISPLAY_AUTHOR_NAME_LEN because it's only displaying '..' rather than the full or truncated name with the .. beside.

 

I can't find where the MAX_AUTHOR_NAME variable has been defined though, but I don't think that would have changed with the changing of a word.. would it?

 

<?php
/*
 $Id: authors.php,v 1.19 2003/06/09 22:17:13 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $authors_query = tep_db_query("select authors_id, authors_name from " . TABLE_AUTHORS . " order by authors_name");
 if ($number_of_rows = tep_db_num_rows($authors_query)) {
?>
<!-- authors //-->
         <tr>
           <td>
<?php
   $info_box_contents = array();
   $info_box_contents[] = array('text' => BOX_HEADING_AUTHORS);

   new infoBoxHeading($info_box_contents, false, false);

   if ($number_of_rows <= MAX_DISPLAY_AUTHORS_IN_A_LIST) {
// Display a list
     $authors_list = '';
     while ($authors = tep_db_fetch_array($authors_query)) {
       $authors_name = ((strlen($authors['authors_name']) > MAX_DISPLAY_AUTHOR_NAME_LEN) ? substr($authors['authors_name'], 0, MAX_DISPLAY_AUTHOR_NAME_LEN) . '..' : $authors['authors_name']);
       if (isset($HTTP_GET_VARS['authors_id']) && ($HTTP_GET_VARS['authors_id'] == $authors['authors_id'])) $authors_name = '<b>' . $authors_name .'</b>';
       $authors_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'authors_id=' . $authors['authors_id']) . '">' . $authors_name . '</a><br>';
     }

     $authors_list = substr($authors_list, 0, -4);

     $info_box_contents = array();
     $info_box_contents[] = array('text' => $authors_list);
   } else {
// Display a drop-down
     $authors_array = array();
     if (MAX_AUTHORS_LIST < 2) {
       $authors_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);
     }

     while ($authors = tep_db_fetch_array($authors_query)) {
       $authors_name = ((strlen($authors['authors_name']) > MAX_DISPLAY_AUTHOR_NAME_LEN) ? substr($authors['authors_name'], 0, MAX_DISPLAY_AUTHOR_NAME_LEN) . '..' : $authors['authors_name']);
       $authors_array[] = array('id' => $authors['authors_id'],
                                      'text' => $authors_name);
     }

     $info_box_contents = array();
     $info_box_contents[] = array('form' => tep_draw_form('authors', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'),
                                  'text' => tep_draw_pull_down_menu('authors_id', $authors_array, (isset($HTTP_GET_VARS['authors_id']) ? $HTTP_GET_VARS['authors_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_AUTHORS_LIST . '" style="width: 100%"') . tep_hide_session_id());
   }

   new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- authors_eof //-->
<?php
 }
?>

Posted

? ? I made it work.

 

It appeared to be a problem with the MAX_DISPLAY_AUTHOR_NAME_LEN variable. By deleting it and replacing it with a numeral, it showed the list up fine.

 

SO my coding went from this:

while ($authors = tep_db_fetch_array($authors_query)) {

? ? ? ?$authors_name = ((strlen($authors['authors_name']) > MAX_DISPLAY_AUTHOR_NAME_LEN) ? substr($authors['authors_name'], 0, MAX_DISPLAY_AUTHOR_NAME_LEN) . '..' : $authors['authors_name']);

? ? ? ?$authors_array[] = array('id' => $authors['authors_id'],

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => $authors_name);

? ? ?}

 

to this:

while ($authors = tep_db_fetch_array($authors_query)) {

? ? ? ? $authors_name = ((strlen($authors['authors_name']) > 20) ? substr($authors['authors_name'], 0, 20) . '..' : $authors['authors_name']);

? ? ? ? $authors_array[] = array('id' => $authors['authors_id'],

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?  'text' => $authors_name);

? ? ? }

  • 2 weeks later...
Posted

Hi Jane,

 

Thanks for posting your fix. I had the same problem with the '..'. One problem down and one more to go. Unfortunately, whenerver I select an item in my new list box - country of origin - it doesn't take me anywhere although manufacturers still works.

 

I figure I need to make some mods to index.php. Any ideas?

 

Thanks again for posting your fix.

 

AJ

Posted
Hi Jane,

 

Thanks for posting your fix.  I had the same problem with the '..'.  One problem down and one more to go.  Unfortunately, whenerver I select an item in my new list box - country of origin - it doesn't take me anywhere although manufacturers still works.

 

I figure I need to make some mods to index.php.  Any ideas?

 

Thanks again for posting your fix.

 

AJ

 

Hey AJ,

 

Is your dropdown in an infobox or your index.php file?

 

The only thing I can think of is perhaps you haven't got the snippet of code which says:

 

onChange="this.form.submit();"

 

which makes your form 'act' when someone selects the dropdown item, rather than waiting for them to hit a submit button.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...