Magento Forum

   
Page 1 of 2
How do i import products into magento automatically? 
 
levis24
Jr. Member
 
Total Posts:  24
Joined:  2008-07-08
 

I`ve heard that you can automatically add products into magento? if this is true how do i do this? because it is taking me
long to add products as i need to duplicate each product 8 times and then create the configurable product.

 
Magento Community Magento Community
Magento Community
Magento Community
 
michaelc
Member
 
Avatar
Total Posts:  64
Joined:  2008-05-21
Qld, Australia
 

After you have setup your attributes, sets and a few products, go to Admin->System->Import/Export->Profiles.
Choose “Export All Products” profile.

If you only have a few products setup, then you can run this profile “as is”. But you may need to customize it to suit what you want exactly. I recommend using and sticking to .csv files for the magento data flow (works best back and forth). The file will export to var/export as default, but again, you can define whatever path you would prefer. You can then copy it to your local PC via FTP.

Open the .csv in MS Excel (I use Openoffice, it treats the text files as text, it doesn’t stuff them around like MS products), and then use this file as a template for adding the rest of you SKUs to for importing.

Adding the image locations to the .csv can be tricky at first, but is very simple when you work out where to place them in the Magento file folder hierarchy. Add all your images to be linked to your product via FTP to /public_html/magento/media/import (this is where magento will look for them). I would also advise that you make sub-directories for your images as well. (NB: If you are only using FTP to upload and manage your files, you will find that when you images number more than 2000, FTP will truncate your view of them, so long term management will become a little difficult. Place images thats naming convention starts with a into an b]a directory, and so on and so forth).

Your .csv file should then represent the images like this:  /i/image.jpg or /image.jpg if you are placing them directly into /media/import. You can assign a different images for “image”, “small_image”, and “thumbnail”, personally, I copy and past the same image to each field, works fine.

Adding and assigning product categories only requires you to enter your product categories corresponding value in your .csv. To work out your category IDs, go to Admin->Catalogue->Category and select each category respectively. In your browsers URL field, it should display a number representing this.... your root category is generally “2” and each category added after adds 1. So in your .csv under category_ids you will simply add your product category ID. If your product falls over a few different categories, then separate with a comma and no space (this one stumped me for a while)…

Last thing, make sure you identify the mandatory fields that magneto uses as identifiers… ie SKU is the product identifier.

Once you have your completed spread sheet, make sure your re-save as a .csv (if you used MS Excel, make sure you open in “Note Pad” and re-save again, this helps to get rid if the MS effect). Go to Admin->System->Import/Export->Profiles. Choose “Import All Products” profile. (I have left all the settings as default, but I have messed with the “Number of records:” This value enables how many records are imported in each process.) Upload your file and then click “Save and Continue” Then got to “Run Profile”, select your imported file (you can find this import via FTP in /public_html/magento/var/import/) and then click “Run Profile in Popup”.

If you have all your fields in your downloaded template correct, the popup will display the import process and then confirm its success after completion. NB: do not close this popup, it will stop the process....

I hope this helps…

 
Magento Community Magento Community
Magento Community
Magento Community
 
michaelc
Member
 
Avatar
Total Posts:  64
Joined:  2008-05-21
Qld, Australia
 

You can also “map” product feeds (XML) from different sources and create a cron job to automate, or use API. Just realized you may have meant something different. Was my last post what you meant??

Not sure, there are a few different ways to do this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Samith_nzl
Jr. Member
 
Total Posts:  15
Joined:  2008-08-11
New Zealand
 

Hey Michaelc,

Have you had any experience with importing configurable products, I can’t work out how to tie my configurable product to my simple products....

Cheers,
Sam

 
Magento Community Magento Community
Magento Community
Magento Community
 
michaelc
Member
 
Avatar
Total Posts:  64
Joined:  2008-05-21
Qld, Australia
 

@Samith_nzi, Yes I have, although our store doesn’t need to utilize them at this stage. What I did to get them working was to create a few “manual” configurable products in the admin console. Then exported them via System->Import/Export->Profiles. This will give you the .csv template to compile your data in with the correct headings. Just pay attention to the maditory fields and their values… then import them again in .csv

Let me know if you run into any problems....

 
Magento Community Magento Community
Magento Community
Magento Community
 
Samith_nzl
Jr. Member
 
Total Posts:  15
Joined:  2008-08-11
New Zealand
 

Thanks for that Michaelc, however I do have one problem, my configurable product does not seem to have any association to my simple products once I imported them.

What I did....

Had 5 products,
1 Configurable Product (made from 2x simple products )
2 Simple products (to make up config product, enabled, display nowhere, in stock, quantity 10 each )
2 Simple products ( shown in other categories )

From my front end I could browse my 3 visible products, one being the configurable one. I could select the two different options I had with that product.
I then went to my system import/export and ran the export-all-products, which I then copied into my import folder and renamed to import instead of export.
Then I deleted all of my 5 products, and went back to the import / export page and ran the “Import all products”, which ran successfully, and imported my 5 products.

However, under manage products my configurable product said it was “Out of stock”, however when I edited it to look at its stock management, I noticed that it didn’t have any simple products associated with it. I can then associate the correct simple products, however I want to be able to do it all from an import, as I have 100+ products each with configurable attributes. 

Ideally I want to just have a large csv file which contains all my simple products and configurable products which I don’t need to modify after import from the magento admin.

Sorry for the long post, but if you have any suggestions on how I can go about this, it would be much appreciated.

Cheers,
Samith_nzl

 
Magento Community Magento Community
Magento Community
Magento Community
 
StefanK
Member
 
Total Posts:  47
Joined:  2008-05-28
 

Hello Michaelc,

do you have an example file, where I could see structure of the file? (e.g. tables, etc...)

Thank you

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
michaelc
Member
 
Avatar
Total Posts:  64
Joined:  2008-05-21
Qld, Australia
 

@Samith_nzl, there should be a field on your exported template that is “is_in_stock” as a header. The values in this field indicate if it is in stock or not. The values that you need here to represent this is only 0 for Out Of Stock or 1 for In Stock. Also, configuable product will only be available if all associated products are “In Stock”. Just double check these values and let me know if it helps.

@StefanK, Unfortunately I can’t get my file to load here (I’ll try again later). Your template file should look different, however, to what you will get out of your store based on how you have set up your product attributes and related attribute sets. The order of the fields and how/where you the add them into a set will reflect this...i.e. adding an attribute called classification to an attribute set called DVD would normally fall under the “Metadata” which is called “Meta Information”...., but if you were to add it under “General” in the attribute set, its order would be different again…

Hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aloeroot
Jr. Member
 
Total Posts:  18
Joined:  2008-07-24
 

Add all your images to be linked to your product via FTP to /public_html/magento/media/import (this is where magento will look for them)…

Your .csv file should then represent the images like this:  /i/image.jpg or /image.jpg if you are placing them directly into /media/import. You can assign a different images for “image”, “small_image”, and “thumbnail”, personally, I copy and past the same image to each field, works fine.

If I’ve got the store under a different path (ie www/shop/media/import for example) would that affect Magento’s ability to find the images in the import folder, and if so is there a way to change the path via the admin area? I’ve followed your instructions for including the images and finding that they won’t show up in the catalog.

I add them to my spreadsheet as, for example, /DSC03869.JPG once they’re in the media/import folder, but they don’t show up after I import the csv file.  Any other ideas? Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
falcarius
Jr. Member
 
Total Posts:  3
Joined:  2008-10-12
 

@Samith_nzl and @michaelc

Hi!

I am still trying to figure out how to associate simple products with configurable products in an csv or xml file and then import it into Magento and keep the association.

If I set up a configurable product with several simple products in Magento and then export it via system->import/export->profile->export all products, there is no field in the exported file that contains the link between the configurable product and the simple products. Hence, I do not know how to “set up” new links in the file either. If I create a new line with a configurable product in the xml/csv file and then import it, there are (naturally) no simple products associated with it.

Any help would be greatly appreciated?

Thanks!
Seb

 
Magento Community Magento Community
Magento Community
Magento Community
 
leruss
Jr. Member
 
Total Posts:  21
Joined:  2008-08-13
 

Hi,

I had the same issue with importing configurable and linked simple products, and the solution described here worked like a charm :
http://www.magentocommerce.com/boards/viewreply/66862/

Hope this help smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
falcarius
Jr. Member
 
Total Posts:  3
Joined:  2008-10-12
 

Great, many thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Don Hays
Jr. Member
 
Total Posts:  11
Joined:  2009-05-28
 

Great Post! But I am having problems with importing products with multiple attribute items. For example I have an attribute called “Age” and the items are Years 0 - 1, Years 1 - 2, etc.. and when I export the product information it comes with the items I’ve selected separated by a comma - space but when I add this information into the CSV I’m creating for the import it does not work. If the field has only one attribute value then it works but as soon as I add a second value separated by a comma space then nothing comes in. I have the CSV set to use
Value Delimiter: ^
Enclose Values In: ~

Could this be causing this issue? Anyone else running into this issue?

TIA,
Don

 
Magento Community Magento Community
Magento Community
Magento Community
 
bolasevich
Sr. Member
 
Avatar
Total Posts:  235
Joined:  2008-03-04
Newington, CT USA
 

my module imports everything mentioned here no problem http://www.magentocommerce.com/extension/1894

 
Magento Community Magento Community
Magento Community
Magento Community
 
lurebeauty
Sr. Member
 
Avatar
Total Posts:  229
Joined:  2009-07-06
 

I found a great post that explains how to automatically group the associated simple products. 

follow the post on this page by user:  oldskool73 ... http://www.magentocommerce.com/boards/viewthread/12709/

I will repost here but give credit to oldskool73 - a job well done!

What this coding does is searches for grouped type products and finds and attaches any related simple products based on a simple ‘LIKE’ match on the sku, e.g grouped product sku="blackstar", matches all simple products with sku="blackstar-1*" i.e “foobar”, “blackstar-2” “blackstar-3” etc will all be added to the group.

Post the coding below before the last } in the following file
app/code/core/Mage/Catalog/controllers/ProductController.php - then visit http://yourstore/catalog/product/autoGroup to run it after you have completed your product import.

public function autoGroupAction() {
        
print "AUTO GROUPING....<br/>";
        
        
$resource Mage::getSingleton('core/resource');
        
$read $resource->getConnection('catalog_read');
        
$productTable $resource->getTableName('catalog/product');
        
$productLinkTable $resource->getTableName('catalog/product_link');
        
$productLinkDecimalTable $resource->getTableName('catalog/product_link_attribute_decimal');
        
$productLinkIntTable $resource->getTableName('catalog/product_link_attribute_int');
        
        
$select_g $read->select()
                           ->
from(array('pt'=>$productTable))
                           ->
where('pt.type_id=?'Mage_Catalog_Model_Product_Type::TYPE_GROUPED);
        
        
$groups $read->fetchAll($select_g);
        print 
"examining ".count($groups)." grouped products...<br/>";
        foreach (
$groups as $group{
            
//find similar skus
            
$sku $group["sku"];
            
$pid $group["entity_id"];
            print 
"::check sku..".$sku."<br/>";
            
$select_p $read->select()
                           ->
from(array('pt'=>$productTable))
                           ->
where('pt.type_id=?'Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
                           ->
where('pt.sku LIKE ?'$sku."%");
            
$products $read->fetchAll($select_p);
            if (
$products{
                
print "---found ".count($products)." related skus...<br/>";
                foreach (
$products as $product{
                    
//check for existing link
                    
$select_i $read->select()
                               ->
from(array('plt'=>$productLinkTable))
                               ->
where('plt.product_id=?',$pid)
                               ->
where('plt.linked_product_id=?'$product["entity_id"])
                               ->
where('plt.link_type_id'3);
                    
$items $read->fetchAll($select_i);
                    print 
"-----prod=".$product["entity_id"].", sku=".$product["sku"]." -- ";
                    if (!
$items{
                        
print "creating new link...";
                        
$insert $read->insert($productLinkTable,Array("product_id"=>$pid,"linked_product_id"=>$product["entity_id"],"link_type_id"=>3));
                        
$last_id $read->lastInsertId();
                        
$insert $read->insert($productLinkDecimalTable,Array("product_link_attribute_id"=>8,"link_id"=>$last_id));
                        
$insert $read->insert($productLinkIntTable,Array("product_link_attribute_id"=>8,"link_id"=>$last_id));
                        print 
"ok<br/>";                    
                    
else {
                        
print "link already exists...<br/>";
                    
}            
                }
            }            
        }
        
    }

Make sure you reindex the catalog under System>Index Management to get the products to update. This worked great for me!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
homebuild
Member
 
Total Posts:  48
Joined:  2009-10-20
 

The easiest way to automatically update and insert products is to go directly to the database.  I almost never use the admin panel to edit products.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 2