Working on a project where I need to convert a webshop from CubeCart to Magento. Have made script that does most of the work. I do it by checking the database what changes I need to apply. File compare is my friend
Below you see that Magento have conneccted a uploaded picture to a product
INSERT INTO `catalog_product_entity_varchar` (`value_id`, `entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
(294, 4, 74, 0, 19, '/a/n/antique_19c._french_libert_gothic_cathedral_clock_1_copy.png'),
- what determine that the folder path should start with /a/n/ or /c/l/ ?? I see it can be various other paths...what determine what the path should be, if I chould make a script that automatically set the path, I need to understand how it work first
Client have 150000 products, and a image folder of 100gb. How can I connect those pictures to magento? Where in the source code of magento can I study how files are uploaded? Do I even have to upload them again as they already are on the server, isn't it enough I give it the htttp reference to where the picture on the server is stored?
just to follow up on why I make a imort script and not using the import feature in Magento:
I tried first to make script that generate a .csv file, butit failed to get validated by magento. So it was either fix it or make my own import script. I chose to my make my own script. But see now that perhaps that is not the best approach.
But here is an issue with export/import from magento: I have clean installation with products that came with template. Exported all products and modifed the SKU of a product in the exported file. So it had different SKU. I want to see that magento listed it as 2 separate products.... but the "check data" found 3 errors on the file, sepite I had only changed 1 SKU
Alright to answer your question: first two letters of an image filename determines category names.
For example this picture antique_19c._french_libert_gothic_cathedral_clock_1_copy.png . First two letters are a and n. So Magento puts it into /a/n. I hope I explained it clearly.
Now with your approach. You are reinventing the wheel. Use Magmi. Google for it and download. Then create a csv like this:
TESTSKU, path_to_image (either path on disk or HTTP(s))
You feed that file to Magmi and it will do all the dirty work. It will save you lots of time.