joechaote Posted July 30, 2004 Posted July 30, 2004 Yesterday, I made a post to the General Support forum asking if there was any way to host multiple stores with different inventories on the same database. Although noone had an answer, I hacked the code a bit and came up with a fairly simple solution. I've decided to share for those who may be interested. First thing's first: Come up with a new store name. We'll call our hypothetical second store "mystore". Unzip the osCommerce package, and copy the catalog directory to the directory you want it installed in for "mystore". We'll call this ~/mystore/catalog. Then edit these files: ~/mystore/catalog/includes/database_tables.php -->edit all table names to be prefixed with 'mystore_' (i.e. 'configuration' --> 'mystore_configuration') ~/mystore/catalog/install/oscommerce.sql --> this one's simple: you can simply perform a "search and replace" for the following strings: replace "DROP TABLE IF EXISTS " with "DROP TABLE IF EXISTS mystore_" replace "CREATE TABLE " with "CREATE TABLE mystore_" replace "INSERT INTO " with "INSERT INTO mystore_" Make sure you include the trailing space on the strings to be replaced or you'll have a big mess on your hands. ~/mystore/catalog/install/functions/database.php --> someone on the dev-team made a boo-boo and referenced a table literally, so you'll have to search & replace "configuration" with "mystore_configuration". --> someone made another boo-boo and made a line begining 'osc_db_query("drop table if exists...etc' Go ahead and comment that out by prepending a // operator to the beginning of the line. (The line should be trivial since the oscommerce.sql file has already been edited to correctly remove pre-existing tables. If you're using your own .sql file or you just want to be cautious, you can go ahead and edit this line by hand to include 'mystore_' before each table name.) ~/mystore/catalog/admin/includes/database_tables.php --> edit the table defines again, as above. After that it should be ready to install either by hadn or by using the ordinary auto-installer. Perhaps support for table prefixes could be included in the next milestone release or elsewhere down the line? It'd be a good feature to have for those of us who want to test product-lines in their own stores before adding them to the main site, or for people who want to run multiple businesses off of the different domains on the same virtual host. Feedback appreciated! -Max
1quicksi Posted July 30, 2004 Posted July 30, 2004 A quick search of the contributions would have lead you to this: http://www.oscommerce.com/community/contri...l/search,stores knowledge base | Contributions | Search
Recommended Posts
Archived
This topic is now archived and is closed to further replies.