Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 35
A suggestion to import configurable products + categories
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

wink I’ts all right!

It pleases to me to know that script worked to you.

About the images: It’s very simple, you only need to copy your images to /media/import (you can do it vía nocturne rsync, cobian backup or similar)

You can try it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
meshbrains
Jr. Member
 
Total Posts:  2
Joined:  2009-04-02
 

amartinez, you’re a life saver! I’ve been struggling with this for days.

One quick question…

I had created the products (simple and configurable) manually and images were uploaded.
Catalog looks fine and images render correctly.
I did an export using Profiles...Export All Products
I then deleted the products in the catalog.
I added the required columns to the csv and followed the rest of your steps to import.

The simple and configurable items are importing with the correct relationships and visibility,
but the image entries in the Product are empty. I verified the image columns in the csv and
verified that the image files haven’t moved on the file system.

Any ideas?

TIA

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

Ah! Don’t mention it! :D

You need to upload your images (with “web-amigable” names) to media/import.

The system put these files in the correct Magento folder’s.

Good luck!

 
Magento Community Magento Community
Magento Community
Magento Community
 
meshbrains
Jr. Member
 
Total Posts:  2
Joined:  2009-04-02
 

That’s the thing that’s wierd… the images are there in the right place and the image path is in the csv.
It’s just that during the import, the image path in the csv doesn’t populate the product entry in the catalog.

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

The folder’s was the correct permissions? You can try to apply 775 or 777 to /media/ and /var/ ?

The ssh command was chmod 775 media/ var/

With any ftp client you can do it too

Regards,

 
Magento Community Magento Community
Magento Community
Magento Community
 
monkeybutler
Jr. Member
 
Total Posts:  17
Joined:  2009-03-11
 

amartinez—thank you so much for this. you have helped so much.

I am having trouble with the image portion as well. Once I go through, I have ALL images listed in the CSV and magento puts all the images in the right folders from media/import to /media/catalog/product etc etc and in the backend, the images are uploaded and the radio buttons are chosen correctly. HOWEVER, “excluded” is checked in the backend, thus not showing any of my product on the front end. Also, when I uncheck “exclude”, the image remains the magento default placeholder image. What am I doing wrong or what can we do to fix this issue?

Anyone else having problems with the images? Has anyone completely figured out the images correctly?

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

Dear monkeybutler… you’re welcome!

I remember some issues about the images:

1/ The field need and slash, like: “/IMG.jpg”

2/ The image filename is case sensitive, all of these are differents filenames: IMG.jpg, img.jpg, img.JPG, Img.Jpg…

3/ Please add a “status” row, with “Enabled” or “Disabled” values (to appear as in_stock or out_of_stock)

4/ For some frontend themes (like blue-theme, etc) please add a “news_from_date” row too (with the full date, like “08-04-2009 00:00:00")

There is another .CSV example:

"sku","store","attribute_set","config_attributes","type","news_from_date","categories","name","image","small_image","thumbnail","options_container","status","visibility","price","weight","description","qty","is_in_stock","shoe_size","associated"
"M.106-S1-39"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","22","1","39",""
"M.106-S1-40"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","21","1","40",""
"M.106-S1-41"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","31","1","41",""
"M.106-S1-42"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","13","1","42",""
"M.106-S1-43"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","20","1","43",""
"M.106-S1-44"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","16","1","44",""
"M.106-S1-45"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","6","1","45",""
"M.106-S1-46"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Disabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","8","1","46",""
"M.106-S1-39"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","25","1","39",""
"M.106-S1-40"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","24","1","40",""
"M.106-S1-41"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","34","1","41",""
"M.106-S1-42"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","16","1","42",""
"M.106-S1-43"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","23","1","43",""
"M.106-S1-44"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","19","1","44",""
"M.106-S1-45"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","9","1","45",""
"M.106-S1-46"
,"default","Shoes","shoe_size","simple","","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","","","","Product Info Column","Enabled","Nowhere","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","11","1","46",""
"M.106-S1"
,"default","Shoes","shoe_size","configurable","08-04-2009 00:00:00","MI MODELO GUAY","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","/M.106-S1.jpg","/M.106-S1.jpg","/M.106-S1.jpg","Product Info Column","Disabled","Catalog, Search","62","3","MI MODELO, NO CONSIGO AUTOMATIZAR ESTO","199","1","","M.106-S1-35,M.106-S1-36,M.106-S1-37,M.106-S1-38,M.106-S1-39,M.106-S1-40,M.106-S1-41,M.106-S1-42,M.106-S1-43,M.106-S1-44,M.106-S1-45,M.106-S1-46,M.106-S1-47,M.106-S1-48"

Hope this help, smile
Antonio

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

Er… nobody know how to automatize this via linux crontab or magento cron? :(

Thank you!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
pdxwebhead
Jr. Member
 
Total Posts:  27
Joined:  2008-07-16
Portland Oregon
 

Thanks so much for this - total lifesaver!

In your example, you have shoe_size as a single attribute under “config_attributes” - what if you also want to bring in a second, or third attribute with a “simple” product, like, say color, and width?  How would you construct that import csv?

Cheers and nice work!

 
Magento Community Magento Community
Magento Community
Magento Community
 
yecine06
Jr. Member
 
Total Posts:  25
Joined:  2009-02-20
 

First let me thank you for sharing your solution

I have used it on a development platform and i have some problems ...

I used the CSV that you gave in exemple, after some problem your some required argument missing i finaly managed to import the products

but the problem is that when i visualize the product on the frontend i can’t choose the soe size ... there isn’t a dropdown box ...

Can you help me please?

 
Magento Community Magento Community
Magento Community
Magento Community
 
pdxwebhead
Jr. Member
 
Total Posts:  27
Joined:  2008-07-16
Portland Oregon
 

Got it figured,

Just wash, rinse and repeat - run a different import for each attribute....

Thanks again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
taylors
Jr. Member
 
Total Posts:  3
Joined:  2009-03-30
 

Hi amartinez,

Figured out the image problem last week.  Thanks!  Now I’m using the category importer on a new installation and the ->getRootCategoryId() function is not working.  I double-checked to make sure a root category is assigned to the store, but it still always returns a value of 0, making the import skip adding categories.  Any idea why this might be?

Also - there is a slight bug where it truncates “s” from category names.  I think I remember the line in _addCategories().  Why have you set it up to do this?

Thanks again for such a great importer!
T

PS - are there any plans to expand this thing to be able to automatically add attributes and attribute sets?  That would really give this tool wings!

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

pdxwebhead: I think every attribute generate a new ‘simple’ line that is linked in the ‘configurable’ line… smile I will try your solution, and try to merge the two import files too.

yecine06: Do you need to uncheck these attributes in catalog - attributes - manage attributes & manage attributes set, to make these items “unrequired”. Or… add these fields to your csv.

taylors: Do you copy the correct .php file to the correct folder, etc etc? What is the version number of that instalattion? I don’t like to edit too much magento code lines, because when you update these installation lost all the changes :( (the solution is to merge it) We go to make a new installation now to revise your question.

see2

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

Looking for the complete process

Er… good. After my infructuous search of the perfect-and-fully-magento-compatible-text-web-browser (arf arf) I change a little the point of view: I only need… to run it! directly! via /usr/bin/php!

In addition, this solve the timeout problem too.

But, for that, I need a new php script, that login, execute the correct import profile, then exit.

Due to the excellent work of Mark_Kimsal and srinigenie (magento-super-heroes) I adapt to my needs the next script:

<?
// ONLY WORK VIA CRON OR SSH: /usr/bin/php -f /var/www/magento/cron_import.php
if (!$_SERVER["HTTP_USER_AGENT"]{

  $profileId 
7;
  
$logFileName'resultado.log';  
  
$recordCount 0;

  require_once 
'app/Mage.php';

  
Mage::app();

  
Mage::log("Inicio",null,$logFileName);  

  
$profile Mage::getModel('dataflow/profile');
  
$userModel Mage::getModel('admin/user');
  
$userModel->setUserId(0);
  
Mage::getSingleton('admin/session')->setUser($userModel);
  
  if (
$profileId{
    $profile
->load($profileId);
    if (!
$profile->getId()) {
      Mage
::getSingleton('adminhtml/session')->addError('ERROR: Perfil incorrecto');
    
}
  }

  Mage
::register('current_convert_profile'$profile);

  
$profile->run();
  
  
$batchModel Mage::getSingleton('dataflow/batch');
  if (
$batchModel->getId()) {
    
if ($batchModel->getAdapter()) {
      $batchId 
$batchModel->getId(); 
      
$batchImportModel $batchModel->getBatchImportModel();
      
$importIds $batchImportModel->getIdCollection();  
      
$batchModel Mage::getModel('dataflow/batch')->load($batchId);      
      
$adapter Mage::getModel($batchModel->getAdapter());
      foreach (
$importIds as $importId{
        $recordCount
++;
        
try{
          $batchImportModel
->load($importId);
          if (!
$batchImportModel->getId()) {
             $errors[] 
Mage::helper('dataflow')->__('WARNING: Skip undefined row');
             continue;
          
}
          $importData 
$batchImportModel->getBatchData();
          try 
{
            $adapter
->saveRow($importData);
          
catch (Exception $e{
            Mage
::log($e->getMessage(),null,$logFileName);          
            continue;
          
}      
          
if ($recordCount&#x50;0 == 0) {
            
Mage::log($recordCount ' completados',null,$logFileName);
          
}
        } 
catch(Exception $ex{
          Mage
::log('Fila ' $recordCount ', SKU ' $importData['sku']' - ERROR: ' $ex->getMessage(),null,$logFileName);        
        
}
      }
      
foreach ($profile->getExceptions() as $e{
        Mage
::log($e->getMessage(),null,$logFileName);          
      
}
    }
  }
  printf
("OK\n");
  
Mage::log("Completado",null,$logFileName);
}
?>

Ok. Let’s go:

1/ Access via ssh to your magento folder (ssh root@your_server_ip)
2/ Go to magneto folder (cd /var/www/magento)
3/ Create some log folder (mkdir -m 777 var/log)
4/ Create the script php file (type “cat > cron_import.php”, intro, paste the code, CTRL-D)
5/ You can add this to your crontab, but you need to be a privilege user in your system (cp /etc/crontab /etc/crontab.bak && echo “00 0 * * * root /usr/bin/php -f /var/www/magento/cron_import.php” >> /etc/crontab)

Note that my profileId is 7, my php executable are in /usr/bin (you can localize yours by typing “locate bin/php")

Now, only rest to upload the name_of_my_impor_file.csv file to /var/www/magento/var/import via remote sync (rsync), ftp, shell script, cobian backup or similar… (perhaps at 23.00 hours, every day, 1 hour before cron job) Ah, and the images to /var/www/magento/media/import, in a similar way.

Wow! It’s run!

Luck,
Antonio

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

2 tips:

* the php script, if you don’t like to copy-paste (like my iphone)

* an obvious suggestion: in the file var/log/resultado.log you can monitorize the results of your import

s2

File Attachments
cron_import.php  (File Size: 3KB - Downloads: 604)
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 35