SilverCart Forum
We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?
You can help us helping you by providing detailed error messages, screenshots and logfile entries.
Page: 1 | ||
Topic CSV Import not working | 3774 Views |
CSV Import not working
21 November 2011 at 5:59pmI am following these directions ive assembled:
1) export product CSV (gets table/column header template)
2) modify/add data (latest test I changed the name of one product, leaving quotes and all other product data, working in MS Notepad)
3) save; maintaining csv and utf8 (ive saved this in sc templates folder but should not matter with absolute link in upload file field?)
3) upload in SC admin
I get No Results Found and returns me to the default SC admin page. Same results whether i try to clear data first or not. I saw that a 'Log' string is being created in the SilvercartProductCsvBulkLoader class but not sure how to view that...
any help guys??
Im newer to PHP so if there is a better way I can track/debug the sequence to sort this out myself please let me know.
I have been able to add/modify products one off
this is SC 1.2
Re: CSV Import not working
22 November 2011 at 9:30pmHi Ben,
we talked about your issues today and apparently have no idea what could cause the problem if the CSV file is correct.
Some of our clients use this feature on a regular basis and we had no issues so far.
Maybe the format gets changed (delimiter e.g.) and this is why the importer is not able to determine any data sets.
Have you already tried to re-import the CSV file without manipulating it?
Cheers
Ramon
Re: CSV Import not working
13 February 2012 at 3:33amI have seen a similar issue while trying to do a CVS import in that nothing is imported and you are returned to the default SC Admin page.
I am happy to provide a login to the admin section of my install and the file I am trying to import.
Bill.
Re: CSV Import not working
13 February 2012 at 9:24amHello Bill,
sorry to hear that this issue still occurs for you.
If you send me the login data and CSV file to "skoehler [at] pixeltricks [dot] de" we'll try to fix this.
Regards,
Sascha
Re: CSV Import not working
14 February 2012 at 1:04amHi Sascha,
Files are on their way.
One thing I noticed this morning is the the export has the fields in a different order to the import requirements.
I think the error of my ways was to export the current list of products, chop out the current products and use it as a framework to build the CVS file for import.
I followed the requirements for Importing that are shown in the Import CVS section, but can still not get an import to happen correctly.
Bill
Re: CSV Import not working
26 April 2012 at 5:39pm Last edited: 26 April 2012 5:44pmLooking at the class SilvercartProductCsvBulkLoader (installfolder/code/backend/SilvercartProductCsvBulkLoader.php), line 46 it declares a public variable '$delimiter' which is defaulted to a semi-colon ';'.
If you are like me, you would normally create a CSV file using a comma (,) and SilverStripe by default also exports to a CSV using a comma (,) hence it not working on the import funtion for products.
To make this work I've added the following code on line 48 in the class SilvercartProductCsvBulkLoader:
public function __construct($objectClass) {
parent::__construct($objectClass);
global $productdelimiter;
if(!empty($productdelimiter)){
$this->delimiter = $productdelimiter;
}
}
and the following code in _config.php
global $productdelimiter;
$productdelimiter = ',';
By doing this you can change the delimiter to whatever you want without having to keep editing the core code.
Thanks SOAL
Re: CSV Import not working
27 April 2012 at 7:59am Last edited: 27 April 2012 8:17amHi SOAL,
great post, thanks for sharing your approach. Maybe using a constant would be better than the global var, since they are usually considered as bad practice. The result would be the same, though.
We'll see if we adapt this regarding the SilvercartProductCsvBulkLoader.We already talked about about a configuration object for such things...
Cheers
Ramon
Re: CSV Import not working
27 April 2012 at 12:30pmI've updated to a constant for best practice.
SilvercartProductCsvBulkLoader.php
public function __construct($objectClass) {
parent::__construct($objectClass);
if(defined('productdelimiter')){
$this->delimiter = productdelimiter;
}
}
_config.php
define('productdelimiter', ',');
Thanks SOAL