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

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

Ok! What I promised.

First, Productwithconfigurablesandcategories.php. Put it under /var/www/magento/app/code/local/Mage/Catalog/Model/Convert/Adapter/

Now, cron_impor_1.3.php. Put it under root folder (by ex. /var/www/magento/) & remember to make it executable (chmod +x cron_import_1.3.php)

And finally, the cron job, something like “00 0 * * * root /var/www/magento/cron_import_1.3.php)

I’m still working in certain details, but it seems to work fine…

Please if you use it let me know!

Notify me about bugs, etc.

Hope it help wink

Antonio

File Attachments
cron_import_1.3.php  (File Size: 4KB - Downloads: 435)
Productwithconfigurablesandcategories.php  (File Size: 14KB - Downloads: 423)
 
Magento Community Magento Community
Magento Community
Magento Community
 
abidwell
Jr. Member
 
Total Posts:  19
Joined:  2009-02-23
 

Antonio
sorry to be so useless - but could you post a fresh example of the csv that you are importing
i have tried checking my attributes and sets - but i still don’t get any errors it just stops
i haven’t tried the cronjob part yet as i haven’t created a cron job before

Starting profile execution, please wait…
Warning: Please don’t close window during importing/exporting data
Starting Mage_Dataflow_Model_Convert_Adapter_Io :: load
Loaded successfully: “/home/tomlodge/public_html/magento/var/import/importconfigurable.csv”
Starting Mage_Dataflow_Model_Convert_Parser_Csv :: parse
Found 17 rows
Starting catalog/convert_adapter_productwithconfigurablesandcategories :: parse

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

of course!

"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"
"EXAMPLE-1-41"
,"default","Shoes","shoe_size","simple","","EXAMPLE COLLECTION","EXAMPLE 3 ANTIK NEGRO","EXAMPLE-1.jpg","EXAMPLE-1.jpg","EXAMPLE-1.jpg","Product Info Column","Enabled","Nowhere","46.899999999999999","3","EXAMPLE 3 ANTIK NEGRO","6","1","41",""
"EXAMPLE-1-47"
,"default","Shoes","shoe_size","simple","","EXAMPLE COLLECTION","EXAMPLE 3 ANTIK NEGRO","EXAMPLE-1.jpg","EXAMPLE-1.jpg","EXAMPLE-1.jpg","Product Info Column","Enabled","Nowhere","46.899999999999999","3","EXAMPLE 3 ANTIK NEGRO","8","1","47",""
"EXAMPLE-1"
,"default","Shoes","shoe_size","configurable","21-04-2009 00:00:00","EXAMPLE COLLECTION","EXAMPLE 3 ANTIK NEGRO","EXAMPLE-1.jpg","EXAMPLE-1.jpg","EXAMPLE-1.jpg","Product Info Column","Enabled","Catalog, Search","46.899999999999999","3","EXAMPLE 3 ANTIK NEGRO","14","1","","EXAMPLE-1-41, EXAMPLE-1-47"
 
Magento Community Magento Community
Magento Community
Magento Community
 
infomix
Jr. Member
 
Total Posts:  1
Joined:  2009-03-07
 

Please i tested your script but this message

# Starting Mage_Dataflow_Model_Convert_Parser_Csv :: parse
# Method “parse” not defined in adapter catalog/convert_adapter_productwithconfigurablesandcategories
# Finished profile execution.

please write exactly steps which files i must to send to which directories… Thank you very much

 
Magento Community Magento Community
Magento Community
Magento Community
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 
infomix - 24 April 2009 11:57 AM

Please i tested your script but this message

# Starting Mage_Dataflow_Model_Convert_Parser_Csv :: parse
# Method “parse” not defined in adapter catalog/convert_adapter_productwithconfigurablesandcategories
# Finished profile execution.

please write exactly steps which files i must to send to which directories… Thank you very much

You need to add the advanced profile in magento admin.

Please read the full post an try again wink

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

A little issue solved. There’s the new scripts.

IMPORTANT:

* In Productwithconfigurablesandcategories.php edit your STORE ROOT CATEGORY ID
* In cron_import_1.3.php, your PROFILE ID
* Look for some new rows added in example.csv:

"websites","has_options","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"
"base"
,"0","EXAMPLE3-1-41","default","Shoes","shoe_size","simple","","EXAMPLE COLLECTION","EXAMPLE 3 ANTIK NEGRO","EXAMPLE3-1.jpg","EXAMPLE3-1.jpg","EXAMPLE3-1.jpg","Product Info Column","Enabled","Nowhere","46.899999999999999","3","EXAMPLE 3 ANTIK NEGRO","6","1","41",""
"base"
,"0","EXAMPLE3-1-47","default","Shoes","shoe_size","simple","","EXAMPLE COLLECTION","EXAMPLE 3 ANTIK NEGRO","EXAMPLE3-1.jpg","EXAMPLE3-1.jpg","EXAMPLE3-1.jpg","Product Info Column","Enabled","Nowhere","46.899999999999999","3","EXAMPLE 3 ANTIK NEGRO","8","1","47",""
"base"
,"1","EXAMPLE3-1","default","Shoes","shoe_size","configurable","21-04-2009 00:00:00","EXAMPLE COLLECTION","EXAMPLE 3 ANTIK NEGRO","EXAMPLE3-1.jpg","EXAMPLE3-1.jpg","EXAMPLE3-1.jpg","Product Info Column","Enabled","Catalog, Search","46.899999999999999","3","EXAMPLE 3 ANTIK NEGRO","14","1","","EXAMPLE3-1-41,EXAMPLE3-1-47"

s2!

File Attachments
Productwithconfigurablesandcategories.php  (File Size: 14KB - Downloads: 322)
cron_import_1.3.php  (File Size: 4KB - Downloads: 330)
 
Magento Community Magento Community
Magento Community
Magento Community
 
abidwell
Jr. Member
 
Total Posts:  19
Joined:  2009-02-23
 

[hi
probably obvious but just to remind people that they need to amend the name of the adapter within the

productwithconfigurablesandcategories.php

class Mage_Catalog_Model_Convert_Adapter_Productwithconfigurablesandcategories
extends Mage_Catalog_Model_Convert_Adapter_Product
{

because the script you posted is pointing to productsimgtest

also my setup is requesting short_description and tax_class_id be added - so I am testing that at the moment

thank you for all your efforts on these scripts though
Tom

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

Oh yes, these change is needed. I’m sorry by the mistake… At this point, I have a lot of .php files that give me crazy!  cheese

 
Magento Community Magento Community
Magento Community
Magento Community
 
abidwell
Jr. Member
 
Total Posts:  19
Joined:  2009-02-23
 

Antonio
Right - i have added the columns that my setup was asking for

It does create the products from your test file ok - but it does not configure the simple product as associated product

when i first go into the Configurable product in Admin Panel - it still prompts me for the variable options (in this example it makes me tick shoe_size

do i need to change my configuration somewhere - should I re-read the post again ?
Tom

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

My example is for shoes store, so if you don’t need shoe_size you can erase it from .CSV and attributes list of administrator.

What is your attribute “linkage”? color? weight?

Are you working with an ERP or exporting manually the data?

The correct way to run the script is under linux shell (ssh or cronjob) like ./cron_import_1.3.php, becauswe since version 1.3.1, the advanced profile menu of magento admin isn’t capable of import and link configurable products. Then, there is a mysql-hack in cron_import_1.3.php that do this job “semi-manually”.

I think there’s possible to move this “hack” from cron_import to the profile .php, but all people run the update via cronjob: this is the goal of this (total automatization)

 
Magento Community Magento Community
Magento Community
Magento Community
 
abidwell
Jr. Member
 
Total Posts:  19
Joined:  2009-02-23
 

ah ok - i will have to play with cronjobs then as i am using SiteGround to do the hosting - so direct command line access is tricky.
I have tried using lynx and tried settting up a cronjob - but no luck yet - and the problem is it doesn’t suggest what went wrong

ah tell a lie - it finally ran the cronjob (i am limited to every 30mins - bit tough for testing)

and it emailed me to say

/bin/sh: root: command not found

the cronjob i am running would be
30**** root /var/www/magento/cron_import_1.3.php

Thanks
Tom

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

these error indicate that the path to your .php file is incorrect.

you can verify the correct path with php_info() by example (copy this to php_info.php to your root magento folder):

<?
php_info();
?>

then go there: http://www.yourdomain.com/phpinfo.php

(WARNING: delete php_info.php after this)

I think the correct path for you was some like ‘/var/vhost/your_name/www/html/magnto_dir/’

in other way, if you want to run the script via lynx, please make this change to cron_import_1.3.php (there is explained in the post):

erase line ‘#!/usr/bin/php’
edit line ‘if (!$_SERVER["HTTP_USER_AGENT"]) {’ with ‘if ($_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"]) {

 
Magento Community Magento Community
Magento Community
Magento Community
 
abidwell
Jr. Member
 
Total Posts:  19
Joined:  2009-02-23
 

Antonio
thanks
i have tried to amend to cronjob to point to a more realistic folder - and will now have to wait !
i will update you on my progress with this

i was also going to ask - if you want to specify multiple attributes such as shoe_size and color - can you comma delimit them in that column or do you have to have repeated records ?

Thanks
Tom

 
Magento Community Magento Community
Magento Community
Magento Community
 
abidwell
Jr. Member
 
Total Posts:  19
Joined:  2009-02-23
 

right i managed to get the cronjob to run by excluding the root part and just calling the full path/file name
i also worked out that i was being stupid and if i change the cronjob to 2minutes in the future every time i want to run it i don’t have to wait 30mins - clearly was getting tired by that point

now the script runs but i get a few errors that i am going to look at - but thought i should post
in fact i cleared these error messages by following Antonio’s post to edit the cron_import_1.3.php

erase line ‘#!/usr/bin/php’
edit line ‘if (!$_SERVER["HTTP_USER_AGENT"]) {’ with ‘if ($_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"]) {

however now the job runs without error - but the product does not create so need to check why that is

previously i got these errors - just for the record
<br /><b>Fatal error</b>: Uncaught exception ‘Exception’ with message ‘Notice: Undefined index: SCRIPT_FILENAME in /home/mysite/public_html/magento/lib/Zend/Controller/Request/Http.php on line 543’
in /home/mysite/public_html/magento/app/code/core/Mage/Core/functions.php:240Stack trace:
#0 /home/mysite/public_html/magento/lib/Zend/Controller/Request/Http.php(543): mageCoreErrorHandler(8, ‘Undefined index...’, ‘/home/mysite/...’, 543, Array)
#1 /home/mysite/public_html/magento/lib/Zend/Controller/Request/Http.php(575): Zend_Controller_Request_Http->setBasePath()
#2 /home/mysite/public_html/magento/app/code/core/Mage/Core/Controller/Request/Http.php(154): Zend_Controller_Request_Http->getBasePath()
#3 /home/mysite/public_html/magento/app/code/core/Mage/Core/Model/Cookie.php(119): Mage_Core_Controller_Request_Http->getBasePath()
#4 /home/mysite/public_html/magento/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php(80): Mage_Core_Model_Cookie->getPath()
#5 /home/mysite/public_html/magento/app/code/core/Mage/Cor in <b>/home/mysite/public_html/magento/app/code/core/Mage/Core/functions.php</b> on line <b>240</b><br />

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

please post here your crontab & the first 5 lines of cron_import_1.3.php

I will try to help you

thank you

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top