Ken44 Posted August 29, 2007 Share Posted August 29, 2007 Hi. Thanks, Surfalot (and all the previous contributors) I downloaded V2.76f r1 this morning. And have spent the day playing with it. I seem to have everything working OK. Would it be possible to add v_manufacturers_Image to the import/export? Or have I missed something? Is there code available to do this? Or does one of the previous versions have this? Ken. Quote Link to comment Share on other sites More sharing options...
mkpenus Posted August 29, 2007 Share Posted August 29, 2007 Hey there. Thanks for this amazing contribution, I have one small, no, not small, huge amazing problem actually :). I'm sorry if this has allready been asked, I tried searching a bit but didn't find a difinive answer, so here goes; For a very, very long time now i've been looking for something like EP, problem is my product_model is not unique, I simply used it for something else than numbers, long before I thought about having to enter more than one product at a time. This is of course something i'm regretting horribly now, but nothing to do about that now. So, I need a way to make EP use products_id (or something like it) which is unique. Now, honestly, i'm willing to pay for this, if I can get a way to enter lots of products at once it will save me so much time i'd almost cry. I still have 10000+ products to enter, so it would be such a relief. If there is allready a version available, or if anyone have the abilities to modify it so I can use it, or make something similar then let me know, if it's something taking alot of time i'll gladly pay for the service. Thanks alot. Michael Quote Link to comment Share on other sites More sharing options...
paulchen2005 Posted August 29, 2007 Share Posted August 29, 2007 Hi surfalot, is there a chance that your contrib works 100% with QTPro ??? can you do this ? thank you very best !!! Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 30, 2007 Share Posted August 30, 2007 Thanks!! It appears it was the POST size in php.ini. I updated it to 64M for my test to work. Actually, my complete max file is 266,000KB so I'll have to try the setting at 300M. ; Maximum size of POST data that PHP will accept. post_max_size = 64M ; was 8M I really think you should ftp that to the temp folder and do a local insert with a file that size. Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 30, 2007 Share Posted August 30, 2007 Hi.Thanks, Surfalot (and all the previous contributors) I downloaded V2.76f r1 this morning. And have spent the day playing with it. I seem to have everything working OK. Would it be possible to add v_manufacturers_Image to the import/export? Or have I missed something? Is there code available to do this? Or does one of the previous versions have this? Ken. I don't know if there are other versions with it. 2.76x versions don't. I'll add it to the wishlist. Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 30, 2007 Share Posted August 30, 2007 Hey there. Thanks for this amazing contribution, I have one small, no, not small, huge amazing problem actually :) . I'm sorry if this has allready been asked, I tried searching a bit but didn't find a difinive answer, so here goes; For a very, very long time now i've been looking for something like EP, problem is my product_model is not unique, I simply used it for something else than numbers, long before I thought about having to enter more than one product at a time. This is of course something i'm regretting horribly now, but nothing to do about that now. So, I need a way to make EP use products_id (or something like it) which is unique. Now, honestly, i'm willing to pay for this, if I can get a way to enter lots of products at once it will save me so much time i'd almost cry. I still have 10000+ products to enter, so it would be such a relief. If there is allready a version available, or if anyone have the abilities to modify it so I can use it, or make something similar then let me know, if it's something taking alot of time i'll gladly pay for the service. Thanks alot. Michael you want to look for a master products capable version. I hear that uses the product id. Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 30, 2007 Share Posted August 30, 2007 Hi surfalot, is there a chance that your contrib works 100% with QTPro ??? can you do this ? thank you very best !!! I know nothing about QTpro Quote Link to comment Share on other sites More sharing options...
Ken44 Posted August 30, 2007 Share Posted August 30, 2007 I'll add it to the wishlist. Thanks Ken Quote Link to comment Share on other sites More sharing options...
paulchen2005 Posted August 30, 2007 Share Posted August 30, 2007 I know nothing about QTpro http://www.oscommerce.com/community/contributions,888 Quote Link to comment Share on other sites More sharing options...
mkpenus Posted August 30, 2007 Share Posted August 30, 2007 you want to look for a master products capable version. I hear that uses the product id. Thanks Surf, could you please explain what you mean though? What is the Master products capable version? And what's different about it? Can it still be used in OSC the same way EP is used? Thanks again Quote Link to comment Share on other sites More sharing options...
bubbasplitshot Posted August 30, 2007 Share Posted August 30, 2007 Thanks!! It appears it was the POST size in php.ini. I updated it to 64M for my test to work. Actually, my complete max file is 266,000KB so I'll have to try the setting at 300M. ; Maximum size of POST data that PHP will accept. post_max_size = 64M ; was 8M more fun.... after getting many things working I was still timing out. the latest was a CGI Timout The specified CGI application exceeded the allowed time for processing. The server has deleted the process. With many thanks to http://www.murraymoffatt.com/software-problem-0002.html I found: The above instructions work for IIS 5.0, which ships with Windows 2000. If you have Windows XP then you've probably got IIS 5.1 and should follow these instuctions: Open IIS. Expand computer name. Right-click on "Web Sites" and choose Properties. Go to "Home Directory" tab. Click the "Configuration" button, brings up another window. Go to the "Process Options" tab. Set as your heart desires. Ok out. -------- But sadly, it doesn't appear to be helping. Even after an IIS reset. How hard would it be to use a backdoor batch method for loading up my 400,000 record .CSV file into the database on my local box? The client needs quarterly updates of this data and I doubt loading 50-100 SPLIT files is going to be smiled upon. How might I call the easypopulate routine from a batch and avoid the web interface entirely? Quote Link to comment Share on other sites More sharing options...
johnpurser Posted August 30, 2007 Share Posted August 30, 2007 Hey Guys, Okay, I have installed the latest version of Easy Poplulate. I download a CSV file to edit, do my edits, and then save. I then upload it to the database. When I check the store, nothing has been updated, even though it gave me no error while updating. I added the model number before saving. Here are my settings, and what message I got after updating. Settings EP vers: 2.76f-MS2 r1 Temp Dir: /hsphere/local/home/aaakirks/aaafabricstoretest.com//catalog/temp/ Temp Dir is Writable Magic Quotes is: off register_globals is: on Split files on: 300 records Model Num Size: 12 Price with tax: false Calc Precision: 2 Replace quotes: false Field seperator: comma Excel safe output: true Preserve tab/cr/lf: false Category depth: 7 Enable attributes: true SEF Froogle URLS: false More Pics: false Unknown Pics: false HTC: false SPPC: false Extra Fields: false File uploaded. Temporary filename: /tmp/phplaxk8Y User filename: EP2007Aug30-1212m_test.txt Size: 12416 Any help would be appreciated!! Quote Link to comment Share on other sites More sharing options...
bubbasplitshot Posted August 30, 2007 Share Posted August 30, 2007 I really think you should ftp that to the temp folder and do a local insert with a file that size. If I set post_max_size = 400M in php.ini then load my 400,000 record .csv file (renamed .txt) into the ./temp directory and try to load it I get: Filename: EP_Split99united.txt Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 369 bytes) in C:\Inetpub\wwwroot\osc\admin\easypopulate.php on line 980 :huh: I'll try splitting the file into largish chunks... I thought i'd have full control to allow this large file to be loaded but I can't seem to get there. Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 31, 2007 Share Posted August 31, 2007 (edited) more fun.... after getting many things working I was still timing out. the latest was a With many thanks to http://www.murraymoffatt.com/software-problem-0002.html I found: The above instructions work for IIS 5.0, which ships with Windows 2000. If you have Windows XP then you've probably got IIS 5.1 and should follow these instuctions: Open IIS. Expand computer name. Right-click on "Web Sites" and choose Properties. Go to "Home Directory" tab. Click the "Configuration" button, brings up another window. Go to the "Process Options" tab. Set as your heart desires. Ok out. -------- But sadly, it doesn't appear to be helping. Even after an IIS reset. How hard would it be to use a backdoor batch method for loading up my 400,000 record .CSV file into the database on my local box? The client needs quarterly updates of this data and I doubt loading 50-100 SPLIT files is going to be smiled upon. How might I call the easypopulate routine from a batch and avoid the web interface entirely? its probably not your web interface causing the problem, EP doesn't handle large catalogs well. You're probably running the poor little thing out of memory in that already memory hungry win sys. Thing is with EP, it was a fantastic idea, executed poorly. With imports, it loads the entire file into memory before doing any processing. Not good for big shop operators. Before the "on the fly" export option I added, it would lookup the entire 8000 product catalog in to memory and build 50-60 MB export files in memory before any output occurred. I've seen 80MB+ MySQL processes spawned on top of that. Your best bet is to chop it up until someone comes up with a better/redesigned version. try splitting it in 50,000 to 100,000 range. Edited August 31, 2007 by surfalot Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 31, 2007 Share Posted August 31, 2007 Thanks Surf, could you please explain what you mean though? What is the Master products capable version? And what's different about it? Can it still be used in OSC the same way EP is used? Thanks again you want to look through the downloads for EP for the mension of support for "Master products" contribution. It uses the product id for identifying the products for update or insert. If you don't have Master products installed on your shop, then you will need to modify the EP you've downloaded to pull out master products support, but leaving the product id part (or install Master products :) ). I'm not supporting those versions, as I know nothing about it. but maybe someone else will step up. Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 31, 2007 Share Posted August 31, 2007 If I set post_max_size = 400M in php.ini then load my 400,000 record .csv file (renamed .txt) into the ./temp directory and try to load it I get: Filename: EP_Split99united.txt Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 369 bytes) in C:\Inetpub\wwwroot\osc\admin\easypopulate.php on line 980 :huh: I'll try splitting the file into largish chunks... I thought i'd have full control to allow this large file to be loaded but I can't seem to get there. Ahh, yup, that's what I was just saying. Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 31, 2007 Share Posted August 31, 2007 Hey Guys, Okay, I have installed the latest version of Easy Poplulate. I download a CSV file to edit, do my edits, and then save. I then upload it to the database. When I check the store, nothing has been updated, even though it gave me no error while updating. I added the model number before saving. Here are my settings, and what message I got after updating. Settings EP vers: 2.76f-MS2 r1 Temp Dir: /hsphere/local/home/aaakirks/aaafabricstoretest.com//catalog/temp/ Temp Dir is Writable Magic Quotes is: off register_globals is: on Split files on: 300 records Model Num Size: 12 Price with tax: false Calc Precision: 2 Replace quotes: false Field seperator: comma Excel safe output: true Preserve tab/cr/lf: false Category depth: 7 Enable attributes: true SEF Froogle URLS: false More Pics: false Unknown Pics: false HTC: false SPPC: false Extra Fields: false File uploaded. Temporary filename: /tmp/phplaxk8Y User filename: EP2007Aug30-1212m_test.txt Size: 12416 Any help would be appreciated!! first, I'd look into getting this path corrected and make absolutely sure (via web host/admin confirmation), that this path is correct and has write permissions for the user that runs your PHP on the server. Also, note the double slash, see the docs and the settings at the top of the file. /hsphere/local/home/aaakirks/aaafabricstoretest.com//catalog/temp/ Quote Link to comment Share on other sites More sharing options...
bubbasplitshot Posted August 31, 2007 Share Posted August 31, 2007 also look at the max upload file size for your php installation (and its setting). that usually won't timeout, but will just dump you to the home page or back to the EP page without a message. Have you tried FTPing the file to the temp folder and importing from there? don't know why you'd get an error just going back a page. I don't recommend testing osCommerce contribs on windowz. I have tried putting my 400,000 record (206MB) .csv file into the temp directory on my host server and loading. It doesn't do it. There is just a reply screen after a few minutes: Easy Populate 2.76e-MS2 - Default Language : english(1) Filename: united_csv.txt I am able to set php.ini (and the values show up in a phpinfo() call), so I've using these settings: ; Maximum allowed size for uploaded files. upload_max_filesize = 300M ; Maximum size of POST data that PHP will accept. post_max_size = 400M ;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; max_execution_time = 900 ; brians, 30 Maximum execution time of each script, in seconds max_input_time = 900 ; brians, was 60 Maximum amount of time each script may spend parsing request data ;max_input_nesting_level = 64 ; Maximum input variable nesting level memory_limit = 256M ;brians 128M, Maximum amount of memory a script may consume (128MB) ----------------- In easypopulate.php I have these updated settings: set_time_limit(3600); //brians, 330 // if you are splitting files, this will set the maximum number of records to put in each file. // if you set your php.ini to a long time, you can make this number bigger define ('EP_SPLIT_MAX_RECORDS', 5000); Settings Temp Dir: /web/osc/temp/ Temp Dir is Writable Magic Quotes is: off Split files on: 5000 records Model Num Size: 32 Price with tax: false Calc Precision: 2 Replace quotes: false Field seperator: comma Excel safe output: true Preserve tab/cr/lf: true Category depth: 7 Enable attributes: true SEF Froogle URLS: false More Pics: false Unknown Pics: false HTC: false SPPC: false Extra Fields: false -------------------- At this point I seem to be unable to load the file through the easypopulate std load, load it via the temp directory, or split it into anything other than small sections which will take a long time to load up piece by piece. Is there something else I can try to get the file loaded? I need to do this quarterly so a strong solution now will be worth the time spent to figure this out! Thanks! Quote Link to comment Share on other sites More sharing options...
surfalot Posted August 31, 2007 Share Posted August 31, 2007 (edited) yeah, I saw all that. my response is post 6169 But that doesn't mean anyone with a better solution couldn't chime in.... :-" Edited August 31, 2007 by surfalot Quote Link to comment Share on other sites More sharing options...
vonstringer Posted September 2, 2007 Share Posted September 2, 2007 Hi there, I have installed Easy Populate 2.76f-MS2 (with attributes) r1 and followed the instructions carefully. Unfortunately when I click on the link Catalog -> Easy Populate in the admin pages I get a completely blank page. There is no source code in the page at all. The problem only occurs on my hosted site. I have a copy of the site on my test server at home and EP works fine. The only differences are the configure.php files and the php versions. I'm sure I have the correct paths in my configure.php files (everything else works, including the file manager) so I was wondering if it was differences in the php configuration? Below are the configuration settings for the hosting server (that EP doesn't work on) and my home server (where EP works fine). Any help greatly appreciated. Hosting server Database: MySQL 5.0.27 HTTP Server: Apache/2.2.3 PHP Version: 5.1.6 osCommerce 2.2-MS2 Home Server Database: MySQL 5.0.26 HTTP Server: Apache/2.2.3 PHP Version: 5.2.0 osCommerce 2.2-MS2 Hosting Server - Home Server allow_call_time_pass_reference Off Off allow_url_fopen On On allow_url_include (not listed) Off always_populate_raw_post_data Off Off arg_separator.input & & arg_separator.output & & asp_tags Off Off auto_append_file no value no value auto_globals_jit On On auto_prepend_file no value no value browscap no value no value default_charset no value no value default_mimetype text/html text/html define_syslog_variables Off Off detect_unicode (not listed) On disable_classes no value no value disable_functions no value no value display_errors Off Off display_startup_errors Off Off doc_root no value no value docref_ext no value no value docref_root no value no value enable_dl On Off error_append_string no value no value error_log no value no value error_prepend_string no value no value error_reporting 2039 6143 expose_php On On extension_dir /usr/lib/php/modules /usr/lib/php5/extensions file_uploads On On highlight.bg #FFFFFF #FFFFFF highlight.comment #FF8000 #FF8000 highlight.default #0000BB #0000BB highlight.html #000000 #000000 highlight.keyword #007700 #007700 highlight.string #DD0000 #DD0000 html_errors On Off ignore_repeated_errors Off Off ignore_repeated_source Off Off ignore_user_abort Off Off implicit_flush Off Off include_path .:/php/includes:/usr/share/php .:/usr/share/php5:/usr/share/php5/PEAR log_errors On On log_errors_max_len 1024 1024 magic_quotes_gpc On Off magic_quotes_runtime Off Off magic_quotes_sybase Off Off mail.force_extra_parameters no value no value max_execution_time 60 30 max_input_time 60 60 memory_limit 16M 16M open_basedir no value no value output_buffering 4096 4096 output_handler no value no value post_max_size 8M 8M precision 14 14 realpath_cache_size 16K 16K realpath_cache_ttl 120 120 register_argc_argv Off Off register_globals On On register_long_arrays On On report_memleaks On On report_zend_debug On On safe_mode Off Off safe_mode_exec_dir no value no value safe_mode_gid Off Off safe_mode_include_dir no value no value sendmail_from no value no value sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i serialize_precision 100 100 short_open_tag On On SMTP localhost localhost smtp_port 25 25 sql.safe_mode Off Off suhosin.log.phpscript (not listed) 0 suhosin.log.phpscript.is_safe (not listed) Off suhosin.log.phpscript.name (not listed) no value suhosin.log.sapi (not listed) no value suhosin.log.script (not listed) no value suhosin.log.script.name (not listed) no value suhosin.log.syslog (not listed) no value suhosin.log.syslog.facility (not listed) no value suhosin.log.syslog.priority (not listed) no value suhosin.log.use-x-forwarded-for (not listed) Off track_errors Off Off unserialize_callback_func no value no value upload_max_filesize 2M 2M upload_tmp_dir no value no value user_dir no value no value variables_order EGPCS GPCS xmlrpc_error_number 0 0 xmlrpc_errors Off Off y2k_compliance On On zend.ze1_compatibility_mode Off Off Quote Link to comment Share on other sites More sharing options...
johnpurser Posted September 2, 2007 Share Posted September 2, 2007 first, I'd look into getting this path corrected and make absolutely sure (via web host/admin confirmation), that this path is correct and has write permissions for the user that runs your PHP on the server. Also, note the double slash, see the docs and the settings at the top of the file./hsphere/local/home/aaakirks/aaafabricstoretest.com//catalog/temp/ Hey surfalot, Thanks for responding!! I bet this is why it's not working, but the only thing is, I looked throught the config files, but I don't really see how to do this. I'm pretty sure that I have permission to write to this directory, becuase I changed the permission myself through my web hosting admin panel. I don't see how to get rid of those double slashes though, any pointers. Thanks!! -John Quote Link to comment Share on other sites More sharing options...
Guest Posted September 3, 2007 Share Posted September 3, 2007 This is based on the easy populate 2.76f-MS2 for file downloads to work I did not do this work but hired some one to make the modifications for me. I haven't done a compare on the EP_v2_76f_r1_MS2 for the differnces My shop I use download products with super download shop I was upgradeing an older version of MS2 to the latest and needed a way for the downloads to work instead of having to add them all in by hand. Super Download Shop can be found here http://www.oscommerce.com/community/contributions,4868/ below is the file easypopulate.php continued in next post Quote Link to comment Share on other sites More sharing options...
Guest Posted September 3, 2007 Share Posted September 3, 2007 looks like will take 2 posts to add the full file <?php /* $Id: easypopulate.php,v 2.76f 2007/01/20 22:50:52 surfalot Exp $ Designed for osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2007 Todd Holforty mtholforty(at)surfalot(dot)com Released under the GNU General Public License */ // Current EP Version define ('EP_CURRENT_VERSION', '2.76f-MS2'); require('includes/application_top.php'); require_once('includes/database_tables.php'); require('easypopulate_functions.php'); // //******************************* //******************************* // C O N F I G U R A T I O N // V A R I A B L E S //******************************* //******************************* ////////////////////////////////////////////////////// // *** Show all these settings on EP main page *** // use this to debug your settings. Copy the settings // to your post on the forum if you need help. ////////////////////////////////////////////////////// define ('EP_SHOW_EP_SETTINGS', true); // default is: false // **** Temp directory **** /* //////////////////////////////////////////////////////////////////////// // // *IF* you changed your directory structure from stock and do not // have /catalog/temp/, then you'll need to change this accordingly. // // *IF* your shop is in the default /catalog/ installation directory // on your website, skip this Temp Directory settings info. // /////////////////////////////////////////////////////////////////////////// CREATING THE TEMP DIRECTORY If your shop is in the root of your public site ( /home/myaccount/public_html/index.php ), you should create a folder called temp from the root of your web space so that the full path looks like this: /home/myaccount/public_html/temp/ Then you must set the permissions to 777. If you don't know how, ask your host. THE DIR_FS_DOCUMENT_ROOT SETTING DIR_FS_DOCUMENT_ROOT is set in your /catalog/admin/includes/configure.php You should look at the setting DIR_FS_DOCUMENT_ROOT setting. if it looks like this (recommended, but doesn't always work): define ('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT); then leave it alone. If it looks like this: define ('DIR_FS_DOCUMENT_ROOT', '/home/myaccount/public_html'); ask your host if the "/home/myaccount/public_html" portion points to your public web space and is correct. Whether you add the trailing slash on the path or not doesn't matter to this contrib, as long as you make the right choice on the following setting. The best thing is to leave it alone as long as your host can confirm it is correct and everything else is working fine. Having said that, NO trailing slash is technically correct. THE DIR_WS_CATALOG & DIR_FS_CATALOG SETTINGS DIR_WS_CATALOG & DIR_FS_CATALOG are set in your /catalog/admin/includes/configure.php They may look like this if your shop is in the root of your web space. If you have something different, don't just change it to this. There is probably a good reason. I'm providing this as a reference to you-all. The DIR_FS_DOCUMENT_ROOT, the DIR_WS_CATALOG, and the DIR_FS_CATALOG settings all combine to create the temp location below. define('DIR_WS_CATALOG', '/'); define('DIR_FS_CATALOG', DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG); THIS EP_TEMP_DIRECTORY SETTING Next, the following setting should set so that the DIR_FS_CATALOG setting plus this following setting makes a correct full path to your temporary location, like this: /home/myaccount/public_html/temp/ if /home/myaccount/public_html/temp/ is the correct full path to your temp location, then: define ('EP_TEMP_DIRECTORY', DIR_FS_CATALOG . 'temp/'); is the correct setting here. Wow, I really hope this stops the forum traffic about this !! ////////////////////////////////////////////////////////////////////////// */ // **** Temp directory **** define ('EP_TEMP_DIRECTORY', DIR_FS_CATALOG . 'shop/temp/'); //**** File Splitting Configuration **** // we attempt to set the timeout limit longer for this script to avoid having to split the files // NOTE: If your server is running in safe mode, this setting cannot override the timeout set in php.ini // uncomment this if you are not on a safe mode server and you are getting timeouts // set_time_limit(330); // if you are splitting files, this will set the maximum number of records to put in each file. // if you set your php.ini to a long time, you can make this number bigger define ('EP_SPLIT_MAX_RECORDS', 300); // default, seems to work for most people. Reduce if you hit timeouts //define ('EP_SPLIT_MAX_RECORDS', 4); // for testing //**** Image Defaulting **** // set them to your own default "We don't have any picture" gif //define ('EP_DEFAULT_IMAGE_MANUFACTURER', 'no_image_manufacturer.gif'); //define ('EP_DEFAULT_IMAGE_PRODUCT', 'no_image_product.gif'); //define ('EP_DEFAULT_IMAGE_CATEGORY', 'no_image_category.gif'); // or let them get set to nothing define ('EP_DEFAULT_IMAGE_MANUFACTURER', ''); define ('EP_DEFAULT_IMAGE_PRODUCT', ''); define ('EP_DEFAULT_IMAGE_CATEGORY', ''); //**** Status Field Setting **** // Set the v_status field to "Inactive" if you want the status=0 in the system define ('EP_TEXT_ACTIVE', 'Active'); define ('EP_TEXT_INACTIVE', 'Inactive'); // Set the v_status field to "Delete" if you want to remove the item from the system define ('EP_DELETE_IT', 'Delete'); // If zero_qty_inactive is true, then items with zero qty will automatically be inactive in the store. define ('EP_INACTIVATE_ZERO_QUANTITIES', false); // default is false //**** Size of products_model in products table **** // set this to the size of your model number field in the db. We check to make // sure all models are no longer than this value. this prevents the database from // getting fubared. Just making this number bigger won't help your database! They must match! // If you increase the Model Number size, you must increase the size of the field // in the database. Use a SQL tool like phpMyAdmin (see your host) and change the // "products_model" field of the "products" table in your osCommerce Database. define ('EP_MODEL_NUMBER_SIZE', 12); // default is 12 //**** Price includes tax? **** // Set the EP_PRICE_WITH_TAX to // false if you want the price that is exported to be the same value as stored in the database (no tax added). // true if you want the tax to be added to the export price and subtracted from the import price. define ('EP_PRICE_WITH_TAX', false); // default is false //**** Price calculation precision **** // US Currency uses 2 digits behind the decimal place, so for the US this should be 2 // NOTE: when entering into the database all prices will be converted to 4 decimal places. define ('EP_PRECISION', 2); // default is 2 // **** Quote -> Escape character conversion **** // If you have extensive html in your descriptions and it's getting mangled on upload, turn this off // set to true = replace quotes with escape characters // set to false = no quote replacement define ('EP_REPLACE_QUOTES', true); // default is false // **** Field Separator **** // change this if you can't use the default of tabs // Tab is the default, comma and semicolon are commonly supported by various progs // Remember, if your descriptions contain this character, you will confuse EP! // if EP_EXCEL_SAFE_OUTPUT if false (below) you must make EP_PRESERVE_TABS_CR_LF false also. $ep_separator = "\t"; // tab is default //$ep_separator = ','; // comma //$ep_separator = ';'; // semi-colon //$ep_separator = '~'; // tilde //$ep_separator = '*'; // splat // define ('EP_SEPARATOR', ); // *** Excel safe output *** // this setting will supersede the previous $ep_separator setting and create a file // that excel will import without spanning cells from embedded commas or tabs in your products. // if EP_EXCEL_SAFE_OUTPUT if false (below) you must make EP_PRESERVE_TABS_CR_LF false also. define ('EP_EXCEL_SAFE_OUTPUT', true); // default is: true if (EP_EXCEL_SAFE_OUTPUT == true) { if ($language == 'english') { $ep_separator = ','; // comma } elseif ($language == 'german') { $ep_separator = ';'; // semi-colon } else { $ep_separator = ','; // comma // default for all others. } } // *** Preserve Tabs, Carriage returns and Line feeds *** // this setting will preserve the special chars that can cause problems in // a text based output. When used with EP_EXCEL_SAFE_OUTPUT, it will safely // preserve these elements in the export and import. define ('EP_PRESERVE_TABS_CR_LF', false); // default is: false // **** Max Category Levels **** // change this if you need more or fewer categories. // set this to the maximum depth of your categories. define ('EP_MAX_CATEGORIES', 7); // default is 7 // VJ product attributes begin // **** Product Attributes **** // change this to false, if do not want to download product attributes define ('EP_PRODUCTS_WITH_ATTRIBUTES', true); // default is true // change this to true, if you use QTYpro and want to set attributes stock with EP. define ('EP_PRODUCTS_ATTRIBUTES_STOCK', false); // default is false // change this if you want to download only selected product options (attributes). // If you have a lot of product options, and your output file exceeds 256 columns, // which is the max. limit MS Excel is able to handle, then load-up this array with // attributes to skip when generating the export. $attribute_options_select = ''; // $attribute_options_select = array('Size', 'Model'); // uncomment and fill with product options name you wish to download // comment this line, if you wish to download all product options // VJ product attributes end // **************************************** // Froogle configuration variables // Here are some links regarding Bulk uploads // http://www.google.com/base/attributes.html // http://www.google.com/base/help/custom-attributes.html // **************************************** // **** Froogle product info page path **** // We can't use the tep functions to create the link, because the links will point to the // admin, since that's where we're at. So put the entire path to your product_info.php page here define ('EP_FROOGLE_PRODUCT_INFO_PATH', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . "product_info.php"); // **** Froogle product image path **** // Set this to the path to your images directory define ('EP_FROOGLE_IMAGE_PATH', HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES); // **** Froogle - search engine friendly setting // if your store has SEARCH ENGINE FRIENDLY URLS set, then turn this to true // I did it this way because I'm having trouble with the code seeing the constants // that are defined in other places. define ('EP_FROOGLE_SEF_URLS', true); // default is false // **** Froogle Currency Setting define ('EP_FROOGLE_CURRENCY', 'USD'); // default is 'USD' // **************************************** // End: Froogle configuration variables // // *********************************** // *** Other Contributions Support *** // *********************************** // More Pics 6 v1.3 define ('EP_MORE_PICS_6_SUPPORT', false); // default is false // // Header Tags Controller Support v2.0 define ('EP_HTC_SUPPORT', true); // default is false // // Separate Pricing Per Customer (SPPC) define ('EP_SPPC_SUPPORT', false); // default is false // /////////////////////////////////////////////////////////////////////////////// // The following items are not complete and untested. Experiment at your own risk. // /////////////////////////////////////////////////////////////////////////////// // // Extra Fields Contribution (***UNTESTED AND MAY NOT BE FUNCTIONAL***) define ('EP_EXTRA_FIELDS_SUPPORT', true); // default is false // // Unknown Image Contrib (***UNTESTED AND MAY NOT BE FUNCTIONAL***) define ('EP_UNKNOWN_ADD_IMAGES_SUPPORT', false); // default is false //******************************* //******************************* // E N D // C O N F I G U R A T I O N // V A R I A B L E S //******************************* //******************************* //******************************* //******************************* // S T A R T // INITIALIZATION //******************************* //******************************* // modify tableBlock for use here. class epbox extends tableBlock { // constructor function epbox($contents, $direct_ouput = true) { $this->table_width = ''; if (!empty($contents) && $direct_ouput == true) { echo $this->tableBlock($contents); } } // only member function function output($contents) { return $this->tableBlock($contents); } } if (!empty($languages_id) && !empty($language)) { define ('EP_DEFAULT_LANGUAGE_ID', $languages_id); define ('EP_DEFAULT_LANGUAGE_NAME', $language); } else { //elari check default language_id from configuration table DEFAULT_LANGUAGE $epdlanguage_query = tep_db_query("select languages_id, name from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_LANGUAGE . "'"); if (tep_db_num_rows($epdlanguage_query) > 0) { $epdlanguage = tep_db_fetch_array($epdlanguage_query); define ('EP_DEFAULT_LANGUAGE_ID', $epdlanguage['languages_id']); define ('EP_DEFAULT_LANGUAGE_NAME', $epdlanguage['name']); } else { echo 'Strange but there is no default language to work... That may not happen, just in case... '; } } $languages = tep_get_languages(); // VJ product attributes begin $attribute_options_array = array(); if (EP_PRODUCTS_WITH_ATTRIBUTES == true) { if (is_array($attribute_options_select) && (count($attribute_options_select) > 0)) { foreach ($attribute_options_select as $value) { $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " where products_options_name = '" . $value . "'"; $attribute_options_values = tep_db_query($attribute_options_query); if ($attribute_options = tep_db_fetch_array($attribute_options_values)){ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']); } } } else { $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id"; $attribute_options_values = tep_db_query($attribute_options_query); while ($attribute_options = tep_db_fetch_array($attribute_options_values)){ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']); } } } // VJ product attributes end // these are the fields that will be defaulted to the current values in // the database if they are not found in the incoming file $default_these = array(); foreach ($languages as $key => $lang){ $default_these[] = 'v_products_name_' . $lang['id']; $default_these[] = 'v_products_description_' . $lang['id']; $default_these[] = 'v_products_url_' . $lang['id']; if (EP_HTC_SUPPORT == true) { $default_these[] = 'v_products_head_title_tag_' . $lang['id']; $default_these[] = 'v_products_head_desc_tag_' . $lang['id']; $default_these[] = 'v_products_head_keywords_tag_' . $lang['id']; } } $default_these[] = 'v_products_image'; if (EP_MORE_PICS_6_SUPPORT == true) { $default_these[] = 'v_products_subimage1'; $default_these[] = 'v_products_subimage2'; $default_these[] = 'v_products_subimage3'; $default_these[] = 'v_products_subimage4'; $default_these[] = 'v_products_subimage5'; $default_these[] = 'v_products_subimage6'; } if (EP_UNKNOWN_ADD_IMAGES_SUPPORT == true) { $default_these[] = 'v_products_mimage'; $default_these[] = 'v_products_bimage'; $default_these[] = 'v_products_subimage1'; $default_these[] = 'v_products_bsubimage1'; $default_these[] = 'v_products_subimage2'; $default_these[] = 'v_products_bsubimage2'; $default_these[] = 'v_products_subimage3'; $default_these[] = 'v_products_bsubimage3'; } $default_these[] = 'v_categories_id'; $default_these[] = 'v_products_price'; $default_these[] = 'v_products_quantity'; $default_these[] = 'v_products_weight'; $default_these[] = 'v_status_current'; $default_these[] = 'v_date_avail'; $default_these[] = 'v_date_added'; $default_these[] = 'v_tax_class_title'; $default_these[] = 'v_manufacturers_name'; $default_these[] = 'v_manufacturers_id'; $filelayout = ''; $filelayout_count = ''; $filelayout_sql = ''; $fileheaders = ''; if ( !empty($dltype) ){ // if dltype is set, then create the filelayout. Otherwise it gets read from the uploaded file list($filelayout, $filelayout_count, $filelayout_sql, $fileheaders) = ep_create_filelayout($dltype, $attribute_options_array, $languages); // get the right filelayout for this download } //******************************* //******************************* // E N D // INITIALIZATION //******************************* //******************************* //******************************* //******************************* // DOWNLOAD FILE (EXPORT) //******************************* //******************************* if ( !empty($_GET['download']) && ($_GET['download'] == 'stream' or $_GET['download'] == 'activestream' or $_GET['download'] == 'tempfile') ){ $filestring = ""; // this holds the csv file we want to download $result = tep_db_query($filelayout_sql); $row = tep_db_fetch_array($result); // $EXPORT_TIME=time(); // start export time when export is started. $EXPORT_TIME = strftime('%Y%b%d-%H%I'); if ($dltype=="froogle"){ $EXPORT_TIME = "FroogleEP" . $EXPORT_TIME; } else { $EXPORT_TIME = "EP" . $EXPORT_TIME; } // Here we need to allow for the mapping of internal field names to external field names // default to all headers named like the internal ones // the field mapping array only needs to cover those fields that need to have their name changed if ( count($fileheaders) != 0 ){ $filelayout_header = $fileheaders; // if they gave us fileheaders for the dl, then use them } else { $filelayout_header = $filelayout; // if no mapping was spec'd use the internal field names for header names } //We prepare the table heading with layout values foreach( $filelayout_header as $key => $value ){ $filestring .= $key . $ep_separator; } // now lop off the trailing tab $filestring = substr($filestring, 0, strlen($filestring)-1); // set the type if ( $dltype == 'froogle' ){ $endofrow = "\n"; } else { // default to normal end of row $endofrow = $ep_separator . 'EOREOR' . "\n"; } $filestring .= $endofrow; if ($download == 'activestream'){ header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=$EXPORT_TIME" . ((EP_EXCEL_SAFE_OUTPUT == true)?".csv":".txt")); // Changed if using SSL, helps prevent program delay/timeout (add to backup.php also) // header("Pragma: no-cache"); if ($request_type== 'NONSSL'){ header("Pragma: no-cache"); } else { header("Pragma: "); } header("Expires: 0"); echo $filestring; } $num_of_langs = count($languages); while ($row){ // if the filelayout says we need a products_name, get it // build the long full froogle image path $row['v_products_fullpath_image'] = EP_FROOGLE_IMAGE_PATH . $row['v_products_image']; // Other froogle defaults go here for now $row['v_froogle_quantitylevel'] = $row['v_products_quantity']; $row['v_froogle_manufacturer_id'] = ''; $row['v_froogle_exp_date'] = date('Y-m-d', strtotime('+30 days')); $row['v_froogle_product_type'] = $row['v_categories_id']; $row['v_froogle_product_id'] = $row['v_products_model']; $row['v_froogle_currency'] = EP_FROOGLE_CURRENCY; // names and descriptions require that we loop thru all languages that are turned on in the store foreach ($languages as $key => $lang){ $lid = $lang['id']; // for each language, get the description and set the vals $sql2 = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE products_id = " . $row['v_products_id'] . " AND language_id = '" . $lid . "' "; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); // I'm only doing this for the first language, since right now froogle is US only.. Fix later! // adding url for froogle, but it should be available no matter what if (EP_FROOGLE_SEF_URLS == true){ // if only one language if ($num_of_langs == 1){ $row['v_froogle_products_url_' . $lid] = EP_FROOGLE_PRODUCT_INFO_PATH . '/products_id/' . $row['v_products_id']; } else { $row['v_froogle_products_url_' . $lid] = EP_FROOGLE_PRODUCT_INFO_PATH . '/products_id/' . $row['v_products_id'] . '/language/' . $lid; } } else { if ($num_of_langs == 1){ $row['v_froogle_products_url_' . $lid] = EP_FROOGLE_PRODUCT_INFO_PATH . '?products_id=' . $row['v_products_id']; } else { $row['v_froogle_products_url_' . $lid] = EP_FROOGLE_PRODUCT_INFO_PATH . '?products_id=' . $row['v_products_id'] . '&language=' . $lid; } } $row['v_products_name_' . $lid] = $row2['products_name']; $row['v_products_description_' . $lid] = $row2['products_description']; $row['v_products_url_' . $lid] = $row2['products_url']; // froogle advanced format needs the quotes around the name and desc $row['v_froogle_products_name_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_name'])) . '"'; $row['v_froogle_products_description_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_description'])) . '"'; // support for Linda's Header Controller 2.0 here if(isset($filelayout['v_products_head_title_tag_' . $lid])){ $row['v_products_head_title_tag_' . $lid] = $row2['products_head_title_tag']; $row['v_products_head_desc_tag_' . $lid] = $row2['products_head_desc_tag']; $row['v_products_head_keywords_tag_' . $lid] = $row2['products_head_keywords_tag']; } // end support for Header Controller 2.0 } // for the categories, we need to keep looping until we find the root category // start with v_categories_id // Get the category description // set the appropriate variable name // if parent_id is not null, then follow it up. // we'll populate an aray first, then decide where it goes in the $thecategory_id = $row['v_categories_id']; $fullcategory = ''; // this will have the entire category stack for froogle for( $categorylevel=1; $categorylevel<=EP_MAX_CATEGORIES; $categorylevel++){ if ($thecategory_id){ $sql2 = "SELECT categories_name FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id = " . $thecategory_id . " AND language_id = " . EP_DEFAULT_LANGUAGE_ID; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); $sql2 = "SELECT categories_image FROM ".TABLE_CATEGORIES." WHERE categories_id = " . $thecategory_id . ''; $result2 = tep_db_query($sql2); $row2 = array_merge($row2, tep_db_fetch_array($result2)); // only set it if we found something $temprow['v_categories_name_' . $categorylevel] = $row2['categories_name']; $temprow['v_categories_image_' . $categorylevel] = $row2['categories_image']; // now get the parent ID if there was one $sql3 = "SELECT parent_id FROM ".TABLE_CATEGORIES." WHERE categories_id = " . $thecategory_id; $result3 = tep_db_query($sql3); $row3 = tep_db_fetch_array($result3); $theparent_id = $row3['parent_id']; if ($theparent_id != ''){ // there was a parent ID, lets set thecategoryid to get the next level $thecategory_id = $theparent_id; } else { // we have found the top level category for this item, $thecategory_id = false; } //$fullcategory .= " > " . $row2['categories_name']; $fullcategory = $row2['categories_name'] . " > " . $fullcategory; } else { $temprow['v_categories_name_' . $categorylevel] = ''; $temprow['v_categories_image_' . $categorylevel] = ''; } } // now trim off the last ">" from the category stack $row['v_category_fullpath'] = substr($fullcategory,0,strlen($fullcategory)-3); // temprow has the old style low to high level categories. $newlevel = 1; // let's turn them into high to low level categories for( $categorylevel=EP_MAX_CATEGORIES; $categorylevel>0; $categorylevel--){ if ($temprow['v_categories_name_' . $categorylevel] != ''){ $row['v_categories_name_' . $newlevel] = $temprow['v_categories_name_' . $categorylevel]; $row['v_categories_image_' . $newlevel] = $temprow['v_categories_image_' . $categorylevel]; $newlevel++; } } // if the filelayout says we need a manufacturers name, get it if (isset($filelayout['v_manufacturers_name'])){ if ($row['v_manufacturers_id'] != ''){ $sql2 = "SELECT manufacturers_name FROM ".TABLE_MANUFACTURERS." WHERE manufacturers_id = " . $row['v_manufacturers_id'] ; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); $row['v_manufacturers_name'] = $row2['manufacturers_name']; } } // If you have other modules that need to be available, put them here // VJ product attribs begin if (isset($filelayout['v_attribute_options_id_1'])){ $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options) { $row['v_attribute_options_id_' . $attribute_options_count] = $attribute_options['products_options_id']; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_options_languages_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_options_languages_values = tep_db_query($attribute_options_languages_query); $attribute_options_languages = tep_db_fetch_array($attribute_options_languages_values); $row['v_attribute_options_name_' . $attribute_options_count . '_' . $lid] = $attribute_options_languages['products_options_name']; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array($attribute_values_values)) { $row['v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values['products_options_values_id']; $attribute_values_price_query = "select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$row['v_products_id'] . "' and options_id = '" . (int)$attribute_options['products_options_id'] . "' and options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "'"; $attribute_values_price_values = tep_db_query($attribute_values_price_query); $attribute_values_price = tep_db_fetch_array($attribute_values_price_values); $row['v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values_price['price_prefix'] . $attribute_values_price['options_values_price']; // systemsmanager begin Downloads $sql = "SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id='" . $attribute_values_price['products_attributes_id'] . "'"; /* if ($row['v_products_id']==18) { // echo "<br>=$sql=<br>"; //print_r($filelayout); } */ $qry = tep_db_query($sql); if (tep_db_num_rows($qry) > 0) { $attrib = tep_db_fetch_array($qry); if ((int)$attrib['products_attributes_filegroup_id'] > 0) { $aux = (int)$attrib['products_attributes_filegroup_id']; //$row['v_attribute_values_filegroup_' . $attribute_options_count . '_' . $attribute_values_count] = (int)$attrib['products_attributes_filegroup_id']; $group = tep_db_fetch_array(tep_db_query("SELECT download_group_name FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS . " WHERE language_id=1 AND download_group_id=" . (int)$attrib['products_attributes_filegroup_id'])); $aux .= "{}" . $group['download_group_name']; $sql = "SELECT a.*, b.* FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS_FILES . " a, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS_TO_FILES . " b WHERE a.download_group_id=" . (int)$attrib['products_attributes_filegroup_id'] . " AND a.download_groups_file_id=b.download_groups_file_id AND b.language_id=1"; $q = tep_db_query($sql); if (tep_db_num_rows($q)) { while ($r = tep_db_fetch_array($q)) { $aux .= "{}" . $r['download_group_filename'] . "{}" . $r['download_group_file_description']; } } $row['v_attribute_values_filegroup_' . $attribute_options_count . '_' . $attribute_values_count] = $aux; } else { $row['v_attribute_values_download_' . $attribute_options_count . '_' . $attribute_values_count] = $attrib['products_attributes_filename']; } //print_r($row); } // systemsmanager end downloads //// attributes stock add start if ( EP_PRODUCTS_ATTRIBUTES_STOCK == true ) { $stock_attributes = $attribute_options['products_options_id'].'-'.$attribute_values['products_options_values_id']; $stock_quantity_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int)$row['v_products_id'] . "' and products_stock_attributes = '" . $stock_attributes . "'"); $stock_quantity = tep_db_fetch_array($stock_quantity_query); $row['v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count] = $stock_quantity['products_stock_quantity']; } //// attributes stock add end for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_values_languages_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_values_languages_values = tep_db_query($attribute_values_languages_query); $attribute_values_languages = tep_db_fetch_array($attribute_values_languages_values); $row['v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid] = $attribute_values_languages['products_options_values_name']; } $attribute_values_count++; } $attribute_options_count++; } } // VJ product attribs end // this is for the separate price per customer module if (isset($filelayout['v_customer_price_1'])){ $sql2 = "SELECT customers_group_price, customers_group_id FROM ".TABLE_PRODUCTS_GROUPS." WHERE products_id = " . $row['v_products_id'] . " ORDER BY customers_group_id" ; $result2 = tep_db_query($sql2); $ll = 1; $row2 = tep_db_fetch_array($result2); while( $row2 ){ $row['v_customer_group_id_' . $ll] = $row2['customers_group_id']; $row['v_customer_price_' . $ll] = $row2['customers_group_price']; $row2 = tep_db_fetch_array($result2); $ll++; } } if ($dltype == 'froogle'){ // For froogle, we check the specials prices for any applicable specials, and use that price // by grabbing the specials id descending, we always get the most recently added special price // I'm checking status because I think you can turn off specials $sql2 = "SELECT specials_new_products_price FROM ".TABLE_SPECIALS." WHERE products_id = " . $row['v_products_id'] . " and status = 1 and expires_date < CURRENT_TIMESTAMP ORDER BY specials_id DESC" ; $result2 = tep_db_query($sql2); $ll = 1; $row2 = tep_db_fetch_array($result2); if( $row2 ){ // reset the products price to our special price if there is one for this product $row['v_products_price'] = $row2['specials_new_products_price']; } } //elari - //We check the value of tax class and title instead of the id //Then we add the tax to price if EP_PRICE_WITH_TAX is set to true $row_tax_multiplier = tep_get_tax_class_rate($row['v_tax_class_id']); $row['v_tax_class_title'] = tep_get_tax_class_title($row['v_tax_class_id']); $row['v_products_price'] = $row['v_products_price'] + (EP_PRICE_WITH_TAX == true ? round( ($row['v_products_price'] * $row_tax_multiplier / 100), EP_PRECISION) : 0); // Now set the status to a word the user specd in the config vars if ( $row['v_status'] == '1' ){ $row['v_status'] = EP_TEXT_ACTIVE; } else { $row['v_status'] = EP_TEXT_INACTIVE; } //print_r($row); // remove any bad things in the texts that could confuse EasyPopulate $therow = ''; foreach( $filelayout as $key => $value ){ //echo "The field was $key<br>"; $thetext = $row[$key]; // kill the carriage returns and tabs in the descriptions, they're killing me! if (EP_PRESERVE_TABS_CR_LF == false || $dltype == 'froogle') { $thetext = str_replace("\r",' ',$thetext); $thetext = str_replace("\n",' ',$thetext); $thetext = str_replace("\t",' ',$thetext); } if (EP_EXCEL_SAFE_OUTPUT == true && $dltype != 'froogle') { // use quoted values and escape the embedded quotes for excel safe output. $therow .= '"'.str_replace('"','""',$thetext).'"' . $ep_separator; } else { // and put the text into the output separated by $ep_separator defined above $therow .= $thetext . $ep_separator; } } // lop off the trailing separator, then append the end of row indicator $therow = substr($therow,0,strlen($therow)-1) . $endofrow; if ($download == 'activestream'){ echo $therow; } else { $filestring .= $therow; } // grab the next row from the db $row = tep_db_fetch_array($result); } // now either stream it to them or put it in the temp directory if ($download == 'activestream'){ die(); } elseif ($download == 'stream'){ //******************************* // STREAM FILE //******************************* header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=$EXPORT_TIME" . ((EP_EXCEL_SAFE_OUTPUT == true)?".csv":".txt")); // Changed if using SSL, helps prevent program delay/timeout (add to backup.php also) // header("Pragma: no-cache"); if ($request_type== 'NONSSL'){ header("Pragma: no-cache"); } else { header("Pragma: "); } header("Expires: 0"); echo $filestring; die(); } elseif ($download == 'tempfile') { //******************************* // PUT FILE IN TEMP DIR //******************************* $tmpfname = EP_TEMP_DIRECTORY . "$EXPORT_TIME" . ((EP_EXCEL_SAFE_OUTPUT == true)?".csv":".txt"); //unlink($tmpfname); $fp = fopen( $tmpfname, "w+"); fwrite($fp, $filestring); fclose($fp); echo "You can get your file in the Tools/File Manager here: " . EP_TEMP_DIRECTORY . "EP" . $EXPORT_TIME . ((EP_EXCEL_SAFE_OUTPUT == true)?".csv":".txt"); die(); } } //******************************* //******************************* // S T A R T // PAGE DELIVERY //******************************* //******************************* ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script type="text/javascript"><!-- function switchForm( field ) { var d = document; var frm = field.form; var tbl = d.getElementById('customtable'); if(d.getElementById) { if(field.options[field.selectedIndex].text == 'Complete' || field.options[field.selectedIndex].text == 'Froogle') { tbl.style.backgroundColor='lightgrey'; for ( var index = 0; index < frm.elements.length; index++ ) { var oElement = frm.elements[ index ]; if ( oElement.type == "checkbox" ) { if ( oElement.checked ) { oElement.checked = false; } oElement.disabled = true; } } } else if(field.options[field.selectedIndex].text == 'Price/Qty' || field.options[field.selectedIndex].text == 'Categories' || field.options[field.selectedIndex].text == 'Attributes' ) { tbl.style.backgroundColor='lightgrey'; for ( var index = 0; index < frm.elements.length; index++ ) { var oElement = frm.elements[ index ]; if ( oElement.type == "checkbox" ) { if ( oElement.checked ) { oElement.checked = false; } if ( (oElement.name == 'epcust_price' || oElement.name == 'epcust_quantity') && field.options[field.selectedIndex].text == 'Price/Qty' ) { oElement.disabled = false; oElement.checked = true; } else if ( oElement.name == 'epcust_category' && field.options[field.selectedIndex].text == 'Categories' ) { oElement.disabled = false; oElement.checked = true; } else if ( oElement.name == 'epcust_attributes' && field.options[field.selectedIndex].text == 'Attributes' ) { oElement.disabled = false; oElement.checked = true; } else { oElement.disabled = true; } } } } else { tbl.style.backgroundColor='white'; for ( var index = 0; index < frm.elements.length; index++ ) { var oElement = frm.elements[ index ]; if ( oElement.type == "checkbox" ) { oElement.disabled = false; } } } } } //--></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top" height="27"> <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <?php require(DIR_WS_INCLUDES . 'column_left.php');?> </table></td> <td class="pageHeading" valign="top"><?php echo "Easy Populate ".EP_CURRENT_VERSION." - Default Language : " . EP_DEFAULT_LANGUAGE_NAME . '(' . EP_DEFAULT_LANGUAGE_ID .')'; ?> <p class="smallText"><?php //******************************* //******************************* // UPLOAD AND INSERT FILE //******************************* //******************************* if (!empty($_POST['localfile']) or (isset($_FILES['usrfl']) && isset($_GET['split']) && $_GET['split']==0)) { if (isset($_FILES['usrfl'])){ // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, EP_TEMP_DIRECTORY); } echo "<p class=smallText>"; echo "File uploaded. <br>"; echo "Temporary filename: " . $file['tmp_name'] . "<br>"; echo "User filename: " . $file['name'] . "<br>"; echo "Size: " . $file['size'] . "<br>"; // get the entire file into an array $readed = file(EP_TEMP_DIRECTORY . $file['name']); } if (!empty($_POST['localfile'])){ // move the file to where we can work with it //$file = tep_get_uploaded_file('usrfl'); //$attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id"; //$attribute_options_values = tep_db_query($attribute_options_query); //$attribute_options_count = 1; //while ($attribute_options = tep_db_fetch_array($attribute_options_values)){ //if (is_uploaded_file($file['tmp_name'])) { // tep_copy_uploaded_file($file, EP_TEMP_DIRECTORY); //} echo "<p class=smallText>"; echo "Filename: " . $_POST['localfile'] . "<br>"; // get the entire file into an array $readed = file(EP_TEMP_DIRECTORY . $_POST['localfile']); } if (EP_EXCEL_SAFE_OUTPUT == true) { // do excel safe input unset($readed); // kill array setup with above code $readed = array(); // start a new one for excel_safe_output $fp = fopen(EP_TEMP_DIRECTORY . (isset($_FILES['usrfl'])?$file['name']:$_POST['localfile']),'r') or die('##Can not open file for reading. Script will terminate.<br />'); // open file $header_line = fgets($fp); if (strpos($header_line,',') !== false) { $ep_separator = ','; } if (strpos($header_line,';') !== false) { $ep_separator = ';'; } if (strpos($header_line,"\t") !== false) { $ep_separator = "\t"; } if (strpos($header_line,'~') !== false) { $ep_separator = '~'; } if (strpos($header_line,'-') !== false) { $ep_separator = '-'; } if (strpos($header_line,'*') !== false) { $ep_separator = '*'; } rewind($fp); while($line = fgetcsv($fp,32768,$ep_separator)) // read new line (max 32K bytes) { unset($line[(sizeof($line)-1)]); // remove EOREOR at the end of the array $readed[] = $line; // add to array we will process later } $theheaders_array = $readed[0]; // pull out header line fclose($fp); // close file } else { // do normal EP input // now we string the entire thing together in case there were carriage returns in the data $newreaded = ""; foreach ($readed as $read){ $newreaded .= $read; } // now newreaded has the entire file together without the carriage returns. // if for some reason excel put qoutes around our EOREOR, remove them then split into rows $newreaded = str_replace('"EOREOR"', 'EOREOR', $newreaded); $readed = explode( $ep_separator . 'EOREOR',$newreaded); // Now we'll populate the filelayout based on the header row. $theheaders_array = explode( $ep_separator, $readed[0] ); // explode the first row, it will be our filelayout } $lll = 0; $filelayout = array(); foreach( $theheaders_array as $header ){ $cleanheader = str_replace( '"', '', $header); // echo "Fileheader was $header<br><br><br>"; $filelayout[ $cleanheader ] = $lll++; // } unset($readed[0]); // we don't want to process the headers with the data // now we've got the array broken into parts by the expicit end-of-row marker. foreach ($readed as $tkey => $readed_row) { process_row($readed_row, $filelayout, $filelayout_count, $default_these, $ep_separator, $languages); // systemsmanager begin downloads reset($filelayout); foreach ($filelayout as $k => $v) { if ($k == 'v_products_model') { $prod = tep_db_fetch_array(tep_db_query("SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_model='" . $readed_row[$v] . "'")); $prid = $prod['products_id']; } if (strpos($k, "_download_") > 0 && $readed_row[$v] != '') { list($option_id, $value_id) = sscanf($k, "v_attribute_values_download_%d_%d"); $attributes_clean_query = "select * from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option_id . "' and options_values_id = '" . $value_id . "'"; $q = tep_db_query($attributes_clean_query); $attrib_id = ''; if (tep_db_num_rows($q) > 0) { $r = tep_db_fetch_array($q); $attrib_id = $r['products_attributes_id']; tep_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = $attrib_id"); } else { $price = $readed_row[$filelayout['v_attribute_values_price_'.$option_id.'_'.$value_id]]; if (substr($price, 0, 1)=='-') $prefix = '-'; else $prefix = '+'; $price = 0 + $price; $price = abs($price); $sql_array = array( 'products_id' => $prid, 'options_id' => $option_id, 'options_values_id' => $value_id, 'options_values_price' => $price, 'price_prefix' => $prefix ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES, $sql_array); $attrib_id = tep_db_insert_id(); } $sql_array = array( 'products_attributes_id' => $attrib_id, 'products_attributes_filename' => $readed_row[$v], 'products_attributes_maxdays' => DOWNLOAD_MAX_DAYS, 'products_attributes_maxcount' => DOWNLOAD_MAX_COUNT ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, $sql_array); } if (strpos($k, "_filegroup_") > 0 && $readed_row[$v] != '') { list($option_id, $value_id) = sscanf($k, "v_attribute_values_filegroup_%d_%d"); $attributes_clean_query = "select * from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option_id . "' and options_values_id = '" . $value_id . "'"; $q = tep_db_query($attributes_clean_query); $attrib_id = ''; if (tep_db_num_rows($q) > 0) { $r = tep_db_fetch_array($q); $attrib_id = $r['products_attributes_id']; tep_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = $attrib_id"); } else { $price = $readed_row[$filelayout['v_attribute_values_price_'.$option_id.'_'.$value_id]]; if (substr($price, 0, 1)=='-') $prefix = '-'; else $prefix = '+'; $price = 0 + $price; $price = abs($price); $sql_array = array( 'products_id' => $prid, 'options_id' => $option_id, 'options_values_id' => $value_id, 'options_values_price' => $price, 'price_prefix' => $prefix ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES, $sql_array); $attrib_id = tep_db_insert_id(); } $arr = explode("{}", $readed_row[$v]); $sql_array = array( 'products_attributes_id' => $attrib_id, 'products_attributes_filename' => 'Group_Files-' . (int)$arr[0], 'products_attributes_filegroup_id' => (int)$arr[0], 'products_attributes_maxdays' => DOWNLOAD_MAX_DAYS, 'products_attributes_maxcount' => DOWNLOAD_MAX_COUNT ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, $sql_array); tep_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS . " WHERE download_group_id=" . $arr[0]); tep_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS_FILES . " WHERE download_group_id=" . $arr[0]); $sql_array = array( 'download_group_id' => $arr[0], 'download_group_name' => $arr[1], 'language_id' => 1 ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS, $sql_array); for ($z=2; $z < count($arr)-1; $z++) { $sql_array = array( 'download_group_id' => $arr[0], 'download_group_filename' => $arr[$z] ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS_FILES, $sql_array); $id = tep_db_insert_id(); $sql_array = array( 'download_groups_file_id' => $id, 'language_id' => 1, 'download_group_file_description' => $arr[$z+1] ); tep_db_perform(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD_GROUPS_TO_FILES, $sql_array); } } } Quote Link to comment Share on other sites More sharing options...
Guest Posted September 3, 2007 Share Posted September 3, 2007 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 3, 2007 Share Posted September 3, 2007 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.