Jump to content

[TIPS] Import CSV


caparuni

Recommended Posts

salah satu fitur PS adalah Import, bisa di akses lewat BO > Tools > Import. dgn fitur ini kita bisa import kategori, produk, atribut, kostumer, dsb. yg paling penting kita harus bikin dulu file .csv, bisa kita bikin di ms-excel ajah biar gampang, terus save ke csv. ada beberapa catatan gw soal fitur import ini.

* yg make versi 1.1 kebawah, harus update /admin/tabs/AdminImport.php. soalnya versi ini buggy abis... cara update nya, yah coba download versi terakhir, buka file zip nya, extract AdminImport.php timpa ke server. (gw seh update make yg 1.2 alpha 1)
* untuk import produk, cobalah untuk selalu masukan product_id, sebenarnya product_id akan otomatis di generate oleh system, tp dalam beberapa kasus ini harus dimasukin kalo ada kolom tag atau image, jd biar aman selalu masukan lah product_id.
* untuk kolom category (import produk), ini harus masukin nya berdasarkan category_id, misalnya 1,2 coba ke BO > catalog, liat category_id (paling kiri). oia untuk Home category_id nya adalah 1
* untuk kolom image, bikin satu folder di hosting/server, misalnya image_import, set chmod 777, upload image nya, format penulisannya path utk imagenya bisa dlm 3 variasi :
1. relative path >> ../image_import/produk.jpg
2. full path >> /home/caparuni/public_html/image_import/produk.jpg (rekomendasi gw seh make yg ini)
3. url >> http://domainanda/image_import/produk.jpg (url ke file image di server/hostingan, bukan ke url ke image di server lain)

segini dulu yah, kalo ada lg nanti gw tambah lg. ;))

Link to comment
Share on other sites

I might have the same problem
et me tell you what i have reached so far: – I noticed that there are some files being created in the /img/tmp directory with permission 600. i cant change their permission because the owner of these files is nobody (the php script). and i think that is why they are not been generated and put in the /img/tmp folder.
-I asked the hosting support people and they told me that the script should not write them with nobody as owner.
so now they removed safemode and they dont allow nobody to write to my domain, so now no files are generated at all
not in the tmp and not in the p folder.
we need someone to guide us as it is a big problem for many people, come one guys, someone clever might understand this. i am happy to work with someone even on phone to troubleshoot it.

Link to comment
Share on other sites

first1 the problem is in ur hosting not in ps. every time the php uploading a filem the permision of the file will be the same with http user/group, since in ur hosting didnt asign a user/group for http service then nobody/nogroup will be asign for an uploaded file. there an options in httpd.conf about user/group for http service, after that still need to add user based on what you set on http.conf. so the solutions on this depend on ur hosting company, since u didnt have a root password ;))
lets make some simple upload script, upload it on the server, and try it. if file is uploaded normaly then the problem is ps.

Link to comment
Share on other sites

I started to like this, it seems that you know what you are talking about. thanks for trying to help.

How do I test it?
What should my host provider change (can you give me specific instruction and i will pass it to them)?
Do you think it is why i cant get the import to work?

Thanks again,

Link to comment
Share on other sites

http://www.php.net/manual/en/features.file-upload.post-method.php theres a sample about uploading files...

<form enctype="multipart/form-data" action="__URL__" method="POST">
   <!-- MAX_FILE_SIZE must precede the file input field -->
   <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
   <!-- Name of input element determines name in $_FILES array -->
   Send this file: <input name="userfile" type="file" />
   <input type="submit" value="Send File" />
</form>

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "";

?>



dont forget to change the $uploaddir to your directory (chmod 777) on server, upload this to a server, try to upload some file

Link to comment
Share on other sites

Ok i have created a file called test.php and pasted the above code in it. I have changed the $uploaddir = '/var/www/uploads/'
to $uploaddir = '/test'

I have created a new folder called test with permission 777 and it is located right under the public_html

It did not work, when i run the test.php and send file, the page gets redirected to another page which prestashp's header and look and it says
We're sorry, but the Web address you entered is no longer available.
To find a product, please type its name in the field below (it is like inside the shop page if you know what i mean).
so i cant tell what this page is trying to say before it gets hijacked

Link to comment
Share on other sites

I have disabled friendly URL , and renamed .htaccess

everytime i import 3 products, i get 3 new files in /img/tmp
/img/tmp/ps_import8kvyyZ
/img/tmp/ps_importmjaTi7
/img/tmp/ps_importoVPZmd

I get something like these names. and /img/p stays empty

Why are these pictures are getting stuck in the /img/tmp directory?

Link to comment
Share on other sites

  • 3 months later...

first1, caparuni, everybody: I have exactly the same problem! Only generated files in img/tmp (chmod 777 !!!) with names e.g. ps_importaP7an6 and 0 bytes (?). Nothing in img/p (chamod 777). Please any advice? Thanks!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...