scottybwoy Posted September 10, 2008 Share Posted September 10, 2008 Hi, I have set up easy cvs, it looks like it has been installed fine, but I think I cocked up the settings. I now get the error "Row 5: The field count doesn't match". I did not see at the bottom of the .ini file that you could disable the languages, so therefore deleted them from the list of headers. As I went down the .ini file I found the language setting bit and did the same there. I also added in my own custom fields, so I don't really know why this message is showing. I carefully matched up the fields with the order number starting with 0, and the error looks like it is pointing to this as the issue. Anyway, here is my .ini settings so you can show me where I am going wrong. ; ###################### GENERAL SETTINGS ########################################### [settings] debug = 0 csv_upload_folder = "csv/" ; if csv file has different columns count (relative to the first row, i.e. column headers), tries to correct it adding blank fields correct_fields_count = 1 ; max number of fields difference to correct (relative to the first row, i.e. column headers) correct_fields_radius = 3 ; default status of imported products products_default_status = 0 ;if no category has been supplied this is used default_category_id = 0 ; add categories if they not exist auto_add_categories = 1 ; images remote load import_images_urls = 1 ; ###################### CSV SETTINGS ########################################### [csv] ; fields separator delimiter = "," ; if empty uses double quotes, so leave blank if you want this. enclosure = "" ; Important for calculating the columns number columns_headers = "category|model|name_en|quantity|availability_id_out_of_stock|image|cost|pric e|description_en|tax class|manufacturer name" columns_headers_delimiter = "|" ;separator character for the subcategories categories_delimiter = "|" categories_subcat_delimiter = "." categories_language = "" ; ###################### DATA BINDINGS ########################################### ; fields names are bound to their corresponding csv colum number (starting from zero) [products] products_model = 1 products_image = 5 products_price = 7 products_quantity = 3 ; products_weight = 11 products_tax_class_id = 9 [categories] categories_id = 0 [manufacturers] manufacturers_id = 10 ;to add or remove a single language just add or remove the language from below (and in cvs of course) [products_description] products_name = "en:2" products_description = "en:7" Thanks for your help. I look forward to using this contrib. P.S. What will it do with the images if they are located remotely? I have some locally and also some from a link like : http://www.tekdroid.com/image.php?sku=WESSTO249 How would it insert that? So far I have the Get Product Images from Remote Server v1.2 Contrib and edit the Image file name to : get_product_image.php?id=WESSTO249 <-- using example above. And then use : http://www.tekdroid.com/image.php?sku= as the pointing url in that contrib. I think this can be easily integrated, and even set up to use multiple servers. Thanks. scottybwoy Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 10, 2008 Share Posted September 10, 2008 I have set up easy cvs, it looks like it has been installed fine, but I think I cocked up the settings. I now get the error "Row 5: The field count doesn't match". ... P.S. What will it do with the images if they are located remotely? First of all i suppose you have a right csv file, actually is comma-separated (,), if you don't know this, you can open your csv file with a notepad and look at the character separating the headers (first row). If it's not comma, you can change it in configuration: [csv] ; fields separator delimiter = "," The error you get is due to the mismatch count of the fields in row #5 against the headers count. I'll change this error in more correct : "Row 5: The count of fields is wrong" Sometimes it is due to empty cells in Excel that aren't written in the exported csv file, so you get a different count along the rows of the file. This situation can be handled in configuration file: ; if csv file has different columns count (relative to the first row, i.e. column headers), tries to correct it adding blank fields correct_fields_count = 1 ; max number of fields difference to correct (relative to the first row, i.e. column headers) correct_fields_radius = 3 try to change the radius value, it's the maximum mismatch tolerance. Outside this value you get a mismatch error. The second question is sbout the images url. You can put an URL inside the image field of your csv file, in this case (supposing you have the CURL PHP library installed, you should) your image will be grabbed and put inside the images folder. The resulting name of this image is the same of the remote one. Let me know if you solved, and thanks for your persistence. Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 10, 2008 Share Posted September 10, 2008 (edited) Sorry i didn't understand at first time... about images url, i can improve it letting specify name and url, but the the image will be grabbed locally Edited September 10, 2008 by eugeniobonifacio Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 10, 2008 Author Share Posted September 10, 2008 By the way, you may not have seen this post I was having the same problem. I found it in your processing script and changed it and now it works fine. Keep up the good work. Another suggestion would be to allow you to update the products_description table on the fly, like in the easy populate module. Also I fount that the tax_id didn't insert properly, unless you put the actual Tax code in. Easy Populate, allows you to put in "VAT" or whatever. Cheers Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 11, 2008 Share Posted September 11, 2008 By the way, you may not have seen this post I was having the same problem. I know this issue, i'm thinking about solving it. Another suggestion would be to allow you to update the products_description table on the fly, like in the easy populate module. Can you be more clear? I don't know how easy populate works. Also I fount that the tax_id didn't insert properly, unless you put the actual Tax code in. Easy Populate, allows you to put in "VAT" or whatever. Sounds strange, in tax_class you can put tax class name (ex 'VAT') or its id, i've tested it and worked. I'll take a look. Quote Link to comment Share on other sites More sharing options...
Tezla Posted September 18, 2008 Share Posted September 18, 2008 Not sure if I was suppose to start a new thread or just post here ... I hope this is ok. I installed the Easy CSV Import 2.0.1 in my osCommerce 2.2ms2. I added the menu option inside the Admin Panel. Installation instructions were good. I used 755 permissions on the “csv” directory. However, I looked through the Readme, and I was unable to find out what the 2 HTML buttons do? They are “Empty Catalog” and “Categories Mapping”. Does “Empty Catalog” really delete all the items in the store? If so, what would be the best way to hide that button because we are only planning to append new items to the existing items. I was afraid to click it. When I click “Categories Mapping” it just says “page not found”… but it might be because I don’t have a file loaded yet? The way we had hoped this to work was to import a batch of new items, and then just go in and add the pictures (we are also using UltraPics 1.2). Is that the way this works? My file is actually in UIEE format (so it needs to be converted to CSV first). Since this accepts the input file from the local PC, I’ll probably just do all the required conversions offline in .NET first. Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 18, 2008 Share Posted September 18, 2008 I was unable to find out what the 2 HTML buttons do? They are “Empty Catalog” and “Categories Mapping”. Does “Empty Catalog” really delete all the items in the store? If so, what would be the best way to hide that button because we are only planning to append new items to the existing items. I was afraid to click it. When I click “Categories Mapping” it just says “page not found”… but it might be because I don’t have a file loaded yet? You were right, i've forgotten to clear those parts of code. Now I cleared and added a configuration option 'allow_empty_db' to enable/disable empty catalog feature (you can empty products's tables). So you should set it to '0'. Categories mapping was an experiment, not needed anymore. You can find the updated version v2.0.2 in osCommerce addons page (http://addons.oscommerce.com/info/4920). Let me know if it's ok. Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 18, 2008 Author Share Posted September 18, 2008 (edited) Hi eugeniobonifacio, I now have your contrib working. Well just updated so yet to test. Although I'm still not getting things working as I would like. I have two extra fields that I want to update to, but they don't get imported. As of my .ini file displayed above, I have two fields; 'cost' and 'availability_id_out_of_stock'. How do I get those to be imported? At the mo I have to go in and manually change them. Also with your new upload image code. Do you write : i_would_like_to_call_this_image_this_please.jpg|http://www.url.to?image=name And would that download the picture to your server, as that name, then scrap the remote link? Thanks for the great contrib. If you have not used easypopulate. I would recommend trying it out as they are both similar but have a few different features. I have both running but it would be good to combine the two to make a super contib. easypopulate also has the prospect of combining the Store Feeds Contrib. Just some ideas for anyone wanting to do it. Keep up the good work. Edited September 18, 2008 by scottybwoy Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 18, 2008 Share Posted September 18, 2008 I have two extra fields that I want to update to, but they don't get imported. As of my .ini file displayed above, I have two fields; 'cost' and 'availability_id_out_of_stock'. How do I get those to be imported? At the mo I have to go in and manually change them. Also with your new upload image code. Do you write : i_would_like_to_call_this_image_this_please.jpg|http://www.url.to?image=name And would that download the picture to your server, as that name, then scrap the remote link? At first, actually the latest release is v2.0.3. If the two fields are in PRODUCTS table, then you should add them to config.ini in "products" section: [products] ... cost = 12 availability_id_out_of_stock = 13 You must use the same name in db table About images, yes the script will grab the picture from the specified url then saves it with the name you put so creating a local image. I will take a look at easypopulate as soon as possible, it's not always easy to find some time. Thank you. Let me know. Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 18, 2008 Author Share Posted September 18, 2008 No worries mate, That's great for now. Thanks for all your support so far. So now I take it that you can set up any db table as a header, i.e. [table_name] And link the fields below it to the order in which they are in your headers string? That's, just what I wanted. Thanks again for a great contrib. I understand you have other things to do, we're all the same, if I get the time myself I may look into doing what I said myself. Cheers, scottybwoy Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 18, 2008 Share Posted September 18, 2008 (edited) So now I take it that you can set up any db table as a header, i.e. Not all tables, this works only for 'products' and 'products_description' tables Edited September 18, 2008 by eugeniobonifacio Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 26, 2008 Author Share Posted September 26, 2008 Hiya, Since I upgraded, I'm getting this error : Warning: readdir(): 58 is not a valid Directory resource in /home/html/klickshopping.co.uk/admin/csv_import.php on line 722 Echoing out CSV_IMPORT_UPLOAD_FOLDER gives me this : csv_import/csv/ which is correct directory with all the write settings etc. And echoing out $handle = Resource id #58 True to the error. Whats wrong with that resource? Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 26, 2008 Share Posted September 26, 2008 Since I upgraded, I'm getting this error : Warning: readdir(): 58 is not a valid Directory resource in /home/html/klickshopping.co.uk/admin/csv_import.php on line 722 mmm try to remove @ char in the following line: if($handle = @opendir(CSV_IMPORT_UPLOAD_FOLDER)) { becomes if($handle = opendir(CSV_IMPORT_UPLOAD_FOLDER)) { it should say something more about, i.e. another warning message. Let me know. Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 26, 2008 Author Share Posted September 26, 2008 No I tried that, still the same message? Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 26, 2008 Author Share Posted September 26, 2008 By the way, the error occurs on the while (false !== ($file = readdir($handle))) { Line. The peculiar thing is is that it allowed me to upload a file to that directory anyhow. However the following line if($file != '.' && $file != '..') { Ensures that nothing is presented after it has reached it, except for the general disclaimer. It acts this way even if I suppress the Warning error by appending readdir with an @. Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted September 29, 2008 Author Share Posted September 29, 2008 I found the error. In your last package you missed of the closing brace for the while loop. When I encountered this problem I put it in the wrong place, it is now in the correct place. <?php } } } closedir($handle); echo '</table>'; } ?> Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 29, 2008 Share Posted September 29, 2008 I found the error. In your last package you missed of the closing brace for the while loop. I checked it and all works right. Which version do you refer to? Try the new v2.1.0 Thanks Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted September 29, 2008 Share Posted September 29, 2008 If someone encounters problems with my contribution and wants to contact me about it, it would be very useful if you tell me your PHP/MySQL versions. Thank you Quote Link to comment Share on other sites More sharing options...
barry100 Posted October 20, 2008 Share Posted October 20, 2008 HI all. I am using this contribution and so far i am very happy with how easy it works. Thing is i have 5000 products to add to my shop. This is going to be easy with this contribution but am looking to add price breaks for every product when people buy over 10 of each. I have installed http://addons.oscommerce.com/info/1242 And I want to be able to use the csv import to populate this attributes tables as well. Is it possible and if so has any one done it so far with success? Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted October 21, 2008 Share Posted October 21, 2008 You should edit your csv_import.php and, after a product has been imported, add some code to manage your new fields (also added to ini file) to be added to the price_break tables. Quote Link to comment Share on other sites More sharing options...
barry100 Posted October 22, 2008 Share Posted October 22, 2008 You should edit your csv_import.php and, after a product has been imported, add some code to manage your new fields (also added to ini file) to be added to the price_break tables. Hi .. This isnt very easy ... What I have done is this I have added to the end of the list of columns in the CSV file 2 columns, 1 called price_break and one called amount in the csv_import.php file i have added $bindings['price_break'] = $config["price_break"]; $bindings['amount'] = $config["amount"]; I dont know if this is the correct thing to do as i have never imported info from a csv file before. Ok then I added this to the csv_import.php file // price break sql $price_break_insert = "INSERT INTO products_price_break (products_price,products_qty ,products_id ) VALUES('".$data['price_break']."','".$data['amount']."' ,'" . $product_id ."')"; // end price break This is inserting the id correctly as to be expected but it is inserting 0 as the other two values. Am I heading in the right direction with what im doing or is it all wrong? Im not sure if i am even getting values from the two new columns? Quote Link to comment Share on other sites More sharing options...
eugeniobonifacio Posted October 23, 2008 Share Posted October 23, 2008 No, you were close. first of all add this lines to csv_import/csv_import.ini just before [categories] section [price_break] price_break = "x" amount = "x" you must replace 'x' with csv column position (starting from 0) then add the following line in csv_import.php after line 115 (just after the other bindings): $bindings['price_break'] = $config["price_break"]; after line 535 (just after languages insert): tep_db_query("INSERT INTO products_price_break (products_price, products_qty, products_id ) VALUES('" . $data[$i][$bindings['price_break']['price_break']] . "','" . $data[$i][$bindings['price_break']['amount']] . "' ,'" . $product_id ."')"); and, for supporting updates, after line 574 (just after languages update): tep_db_query("UPDATE products_price_break SET products_price = '" . $data[$i][$bindings['price_break']['price_break']] . "', products_qty = '" . $data[$i][$bindings['price_break']['amount']] . "' WHERE products_id = " . $product_id . ""); I didn't test all this changes, there could be some syntax error, but it shoul do what you want. Let me know. Quote Link to comment Share on other sites More sharing options...
barry100 Posted October 23, 2008 Share Posted October 23, 2008 Thanks so much for your help. That worked absolutely perfectly. I am happiest man alive today!! Love your contributions and thanks for the help also!! ;) Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted November 21, 2008 Author Share Posted November 21, 2008 Hi I have another problem. I am using a contrib that adds a second description field, and am trying to get it to insert it into the database. In the csv_import.ini file I have added : columns_headers = "category|model|name_en|quantity|availability|weight|image|cost|price|descrip tion_en|features_en|tax class|manufacturer name" products_description2 = "en:10" But it doesn't seem to add it to the database. Any ides? Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted November 21, 2008 Author Share Posted November 21, 2008 Don't worry I sorted it by adding this code : // descriptions2 decoding $products_descriptions2_codes = explode(',', $descriptions['products_description2']); foreach($products_descriptions2_codes as $v) { list($code, $col) = explode(':', $v); $bindings['products_description'][trim($code)]['products_description2'] = $col; } to decode_bindings method. Cheers for the great contrib 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.