Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
A suggestion to import configurable products + categories
 
freshman66
Jr. Member
 
Total Posts:  25
Joined:  2009-04-29
 

If anybody wondered why the gallery import doesn’t work: there’s a slash missing in the Productimport.php. Look for this part:

if ( !empty( $importData['gallery') ) {
            $galleryData 
explode','$importData["gallery");
            foreach( 
$galleryData as $gallery_img {
                
try {
                    $product 
-> addImageToMediaGalleryMage :: getBaseDir'media' ) . DS 'import' $gallery_imgnullfalsefalse );
                    

                
catch ( Exception $e {
                    } 
                } 
            }

and add a slash behind ‘Mage :: getBaseDir( ‘media’ ) . DS . ‘import/’.

Cheers, The Freshman

 
Magento Community Magento Community
Magento Community
Magento Community
 
TimW
Jr. Member
 
Total Posts:  8
Joined:  2009-01-16
 

First off, this is a fantastic script and a HUGE asset to the Magento community. Thank you for sharing it.

I’m having trouble importing a configurable product with 286 simple products configured on 2 attributes. The simple products are already in the database, and my sample import file is listed below. I get a partial import, where only 43 of the total 286 simple products are assigned to the new configurable product.

I am using Magento 1.2.0.2 and the Productwithconfigurablesandcategories.php file attached to the first post of this thread. Also, I’m doing the import from the admin and not a cron job. There are no errors during import.

Has anyone had success with configurable products associated with large quantities of simple products? Any advice is appreciated.

Thanks in advance!

"store","websites","type","status","options_container","gift_message_available","tax_class_id","visibility","disable_googlecheckout","qty","min_qty","use_config_min_qty","is_qty_decimal","backorders","use_config_backorders","min_sale_qty","use_config_min_sale_qty","max_sale_qty","use_config_max_sale_qty","is_in_stock","low_stock_date","notify_stock_qty","use_config_notify_stock_qty","manage_stock","use_config_manage_stock","stock_status_changed_automatically","has_options","custom_design","custom_layout_update","sku","image","small_image","thumbnail","url_key","url_path","attribute_set","config_attributes","required_options","category_ids","gender","shoe_width","made_in","shoe_mfr_ecco_colors","shoe_mfr_mbt_colors","manufacturer","shoe_mfr_sku","shoe_store_sku","men_shoe_size_us","women_shoe_size_us","name","weight","price","image_label","small_image_label","thumbnail_label","shoe_feat_upper","shoe_feat_outsole","shoe_feat_toe","shoe_feat_lining","shoe_feat_insole","shoe_feat_sole","shoe_feat_1","shoe_feat_2","shoe_feat_3","shoe_feat_4","shoe_feat_5","shoe_feat_6","description","short_description","meta_keyword","meta_title","meta_description","associated"
"admin"
,"base","configurable","Enabled","Block after Info Column","Use config","Taxable Goods","Catalog, Search","No"," ","0","1","0","0","1","1","1","0","1","1",,,"1","0","1","0","1",,,"2009_ECCO_TEST-M","/68104-55104_STONE.jpg","/68104-55104_STONE.jpg","/68104-55104_STONE.jpg","ecco-savage-low-(stone)","ecco-savage-low-(stone).html","Mfr_ECCO_Men","men_shoe_size_us,shoe_width","0","3,6","Men's",,"Thailand","Stone",,"ECCO","68104-55104","68104-55104",,,"ECCO TEST PRODUCT","2","180","ECCO Savage Low","ECCO Savage Low","ECCO Savage Low","Oil Nubuck Leather & Textile","Traction Rubber",,"Textile lining","Direct-injected PU midsole",,"Full-length Receptor technology","Gore-Tex waterproof system",,,,,"Long description: The Savage is an outdoor casual shoe with plenty of cushion and support for all your outdoor needs.","The Savage is an outdoor casual shoe with plenty of cushion and support for all your outdoor needs.",,,,"2009_ECCO_TEST-M-10-2A,2009_ECCO_TEST-M-10-2E,2009_ECCO_TEST-M-10-3E,2009_ECCO_TEST-M-10-4E,2009_ECCO_TEST-M-10-5E,2009_ECCO_TEST-M-10-6E,2009_ECCO_TEST-M-10-9E,2009_ECCO_TEST-M-10-A,2009_ECCO_TEST-M-10-ADJ,2009_ECCO_TEST-M-10-B,2009_ECCO_TEST-M-10-C,2009_ECCO_TEST-M-10-D,2009_ECCO_TEST-M-10-E,2009_ECCO_TEST-M-10.5-2A,2009_ECCO_TEST-M-10.5-2E,2009_ECCO_TEST-M-10.5-3E,2009_ECCO_TEST-M-10.5-4E,2009_ECCO_TEST-M-10.5-5E,2009_ECCO_TEST-M-10.5-6E,2009_ECCO_TEST-M-10.5-9E,2009_ECCO_TEST-M-10.5-A,2009_ECCO_TEST-M-10.5-ADJ,2009_ECCO_TEST-M-10.5-B,2009_ECCO_TEST-M-10.5-C,2009_ECCO_TEST-M-10.5-D,2009_ECCO_TEST-M-10.5-E,2009_ECCO_TEST-M-11-2A,2009_ECCO_TEST-M-11-2E,2009_ECCO_TEST-M-11-4E,2009_ECCO_TEST-M-11-5E,2009_ECCO_TEST-M-11-6E,2009_ECCO_TEST-M-11-9E,2009_ECCO_TEST-M-11-A,2009_ECCO_TEST-M-11-ADJ,2009_ECCO_TEST-M-11-B,2009_ECCO_TEST-M-11-C,2009_ECCO_TEST-M-11-D,2009_ECCO_TEST-M-11-E,2009_ECCO_TEST-M-11.5-2A,2009_ECCO_TEST-M-11.5-2E,2009_ECCO_TEST-M-11.5-3E,2009_ECCO_TEST-M-11.5-4E,2009_ECCO_TEST-M-11.5-5E,2009_ECCO_T"

 
Magento Community Magento Community
Magento Community
Magento Community
 
oleksi
Jr. Member
 
Total Posts:  7
Joined:  2009-05-30
 
cyrilthemonkey - 14 July 2009 09:26 AM

I’ve solved it now, and it works.

Thanks oleksi.

Basically, make sure you’re careful sorting the SKU column in your CSV file. If you have SKUs like shirt1-small, shirt1-medium, shirt1-large etc. make sure they’re higher on the list (and so get uploaded before) your configurable products which have data in the associated column and have SKUs like shirt1.

I’ve been pulling my hair out for hours - and all it took was something so easy!

Yeah, that’s another thing! Glad you figured it out. I’m having another problem now. I have to bulk import more than 4000 attribute options and when I do this they stop showing up in admin interface.

 
Magento Community Magento Community
Magento Community
Magento Community
 
TimW
Jr. Member
 
Total Posts:  8
Joined:  2009-01-16
 

I shortened up my product skus and now I can import 54 associations with the script. It appears my problem is related to the sku length. Is a variable or field getting maxed out?

UPDATE:

I added an echo statement for the $importData[’associated’]; variable to see what it had. It only has the first 54 skus. So the problem must be occurring in the code that parses the csv file…

UPDATE:

My mistake.... I had bad CSV files from the get go. The script is working properly. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
freshman66
Jr. Member
 
Total Posts:  25
Joined:  2009-04-29
 

Hi all,
once again I am facing a new problem when importing products and categories the way we do in this script.

Importing for a single language now works fine, even with tier prices and without SQL-injections. The problem starts when you add a second language (store view).

Obviously you will have to create your categories in the new language - but by adding them to your default root category id you’ll end up with a category tree that consists of multiple languages. Of course I could have a separate store with their respective root ids, but that doesn’t seem the way to do it.

Has anybody run into that issue and might have a solution?

Cheers, Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
freshman66
Jr. Member
 
Total Posts:  25
Joined:  2009-04-29
 

Hi again,

I did manage to rewrite the import script so that now you can import categories with multiple languages. If anybody is interested in the mod please let me know.

Also, I stumbled upon another bug in the original script which prevents the correct caching of categories and might result in slower performance. Look for this code in the method _addCategories

if ( !empty( $cache[$categoryPathStr] ) ) {
                $catIds[] 
$cache[$categoryPathStr] -> getId();
                continue;
}

and replace it with

if ( !empty( $cache[strtolower($categoryPathStr)) ) {
                $catIds[] 
$cache[strtolower($categoryPathStr)-> getId();
                continue;
                
}

Cheers, Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
freshman66
Jr. Member
 
Total Posts:  25
Joined:  2009-04-29
 

Hello people,

when I started to import my data into different stores I ran into an error that has been mentioned before in this thread by Pooch.

Fatal errorCall to a member function getPath() on a non-object in app\code\core\Mage\Catalog\Model\Resource\Eav\Mysql4\Category.php on line 385

Obviously something is wrong with adding of the categories and after hours I was able to track the cause down to the resource class “Mage_Catalog_Model_Resource_Eav_Mysql4_Category”. In the method _getTree the private variable $_tree gets set and remains set whenever we are in our loop category adding loop.

This means that the tree doesn’t get reloaded in every loop which in turn causes the problem.

My quick and dirty solution in “Mage_Catalog_Model_Resource_Eav_Mysql4_Category” was this

protected function _getTree()
    
{
        
//if (!$this->_tree) {
            
$this->_tree Mage::getResourceModel('catalog/category_tree')
                ->
load();
        
//}
        
return $this->_tree;
    
}

which is of course not the correct way to do it. Does anybody have an idea how I can reset that private variable from outside the object or destroy the $cat object in every loop?

Probably an easy question, but I am out of ideas.

The funny thing is that this error does not occur on my local installation of Magento and also only when more than one store is enabled.

Thanks for your help, Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaybenfield
Jr. Member
 
Total Posts:  16
Joined:  2009-04-21
Washington DC
 

First of all amartinez, if you’re ever in the DC area I’ll buy you a cup of coffee! I just implemented your script on a store running 1.3.2.1. Thank you.

The missing piece of the puzzle at this point is adding prices to the associated products/options after import in an automated fashion. The store will have hundreds of configurable products, each associated to the same 25 simple products. After importing, I need to be able to push the pricing to all of the configurable products. And from an ongoing maintenance perspective, once the pricing is in place I need the ability to update pricing for a given simple product option ("change the price of XYZ on all configurable products from $10 to $15").

I’m digging through the forums right now, but if anyone has any pointers, a script, or some raw SQL that fits the bill, I would greatly appreciate it.

Thanks!
Jay

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

Can you use grouped products?

These configurable options are single or multiple?

Thanks by the cofee!

jaybenfield - 18 July 2009 04:48 PM

First of all amartinez, if you’re ever in the DC area I’ll buy you a cup of coffee! I just implemented your script on a store running 1.3.2.1. Thank you.

The missing piece of the puzzle at this point is adding prices to the associated products/options after import in an automated fashion. The store will have hundreds of configurable products, each associated to the same 25 simple products. After importing, I need to be able to push the pricing to all of the configurable products. And from an ongoing maintenance perspective, once the pricing is in place I need the ability to update pricing for a given simple product option ("change the price of XYZ on all configurable products from $10 to $15").

I’m digging through the forums right now, but if anyone has any pointers, a script, or some raw SQL that fits the bill, I would greatly appreciate it.

Thanks!
Jay

 Signature 

amartinez {web/developer/designer} free modules: CustomImportExport Like it? Donate!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Limetree Web Design
Member
 
Total Posts:  40
Joined:  2009-01-03
 

My first round of imports worked just fine, so I tried to upload a second set of products.

But when I go to the configurable product’s backend profile, after importing, it opens with the “Select Configurable Attributes” page asking me to choose my configurable attribute (which is ‘shirt_size’).  Unless I highlight the right attribute, it won’t work and display the configurable product’s options on the frontend.

The thing is, I don’t think individually selecting the attribute for 5000 products is practical!  I used the same .csv layout as before, so I don’t know where else I’m going wrong.

Any ideas?

 Signature 

Limetree Design

 
Magento Community Magento Community
Magento Community
Magento Community
 
Limetree Web Design
Member
 
Total Posts:  40
Joined:  2009-01-03
 

Once again, I’ve fixed my own silly problem.

If you’re being asked to select the configurable attribute option for each product in the backend, make sure the configurable products ‘has_option’ column is set to ‘0’ in your .csv

 Signature 

Limetree Design

 
Magento Community Magento Community
Magento Community
Magento Community
 
Limetree Web Design
Member
 
Total Posts:  40
Joined:  2009-01-03
 

No, it’s still not fixed.

Does anybody know how I can bypass the Select Configurable Attribute page for each configurable product on the backend?

I don’t want to have to manually select ‘Shirt Size’ for 5,000 products.  I didn’t have to when I imported configurable products into a different Magento store.  Only with this store.

 Signature 

Limetree Design

 
Magento Community Magento Community
Magento Community
Magento Community
 
tegansnyder
Member
 
Avatar
Total Posts:  45
Joined:  2008-10-23
 

I’m running Magento version 1.3.2.1. My configurable and simple products import just fine. When I’m in the admin I can clearly see that my configurable products have associated products attached to them. HOWEVER the associated products don’t show up on the website.

What’s weird is that I can get them to show up by visiting a simple product in the admin and clicking on the “Associated” link in the left nav and then click “Save”.

It’s almost like it isn’t saving the simple products correctly.

Anybody with a free moment care to look over the following files:

Here is my advanced profile:

<action type="dataflow/convert_adapter_io" method="load">
    <var 
name="type">file</var>
    <var 
name="path">var/import</var>
    <var 
name="filename"><![CDATA[product_import.csv]]></var>
    <var 
name="format"><![CDATA[csv]]></var>
</
action>

<
action type="dataflow/convert_parser_csv" method="parse">
    <var 
name="delimiter"><![CDATA[,]]></var>
    <var 
name="enclose"><![CDATA["]]></var>
    <var name="
fieldnames">true</var>
    <var name="
store"><![CDATA[0]]></var>
    <var name="
number_of_records">1</var>
    <var name="
decimal_separator"><![CDATA[.]]></var>
    <var name="
adapter">catalog/convert_adapter_productimport</var>
    <var name="
method">parse</var>
</action>

My CSV is named product_import.csv

Here is a sample of the CSV:

sku,websites,store,has_options,type,attribute_set,config_attributes,news_from_date,categories,name,image,small_image,thumbnail,options_container,status,tax_class_id,visibility,weight,price,description,short_description,qty,is_in_stock,shirt_color,shirt_size,associated
DU8711
-D21X-CAMO-UNIT,base,default,0,simple,JDoesInc Product,"shirt_color,shirt_size",,"Men's, Gifts",Men's Med Profile Cap,,,,Product Info Column,Enabled,Taxable Goods,Nowhere,0.21,$9.99 ,some words,Men's Med Profile Cap,12,1,CAMO,UNIT,
DU8711-D21X,base,default,1,configurable,JDoesInc Product,"shirt_color,shirt_size",,"Men's, Gifts",Men's Med Profile Cap,/DU8711_CAMO_D21X_F.jpg,/DU8711_CAMO_D21X_F.jpg,/DU8711_CAMO_D21X_B.jpg,,Enabled,Taxable Goods,"Catalog, Search",0.21,$9.99 ,some words,Men's Med Profile Cap,0,1,,,DU8711-D21X-CAMO-UNIT
DU8710
-D37A-KHA-UNIT,base,default,0,simple,JDoesInc Product,"shirt_color,shirt_size",,"Men's, Gifts",Men's Low Profile Cap,,,,Product Info Column,Enabled,Taxable Goods,Nowhere,0.25,$9.99 ,some words,Men's Low Profile Cap,12,1,KHA,UNIT,
DU8710-D37A,base,default,1,configurable,JDoesInc Product,"shirt_color,shirt_size",,"Men's, Gifts",Men's Low Profile Cap,/DU8710_251_D37A_F.jpg,/DU8710_251_D37A_F.jpg,/DU8710_251_D37A_B.jpg,,Enabled,Taxable Goods,"Catalog, Search",0.25,$9.99 ,some words,Men's Low Profile Cap,0,1,,,DU8710-D37A-KHA-UNIT
DU8709
-D21Z-688-UNIT,base,default,0,simple,JDoesInc Product,"shirt_color,shirt_size",,"Ladies, Gifts",Ladies Pink and Khaki Cap,,,,Product Info Column,Enabled,Taxable Goods,Nowhere,0.21,$9.99 ,some words,Ladies Pink and Khaki Cap,12,1,688,UNIT,
DU8709-D21Z,base,default,1,configurable,JDoesInc Product,"shirt_color,shirt_size",,"Ladies, Gifts",Ladies Pink and Khaki Cap,/DU8709_688_D21Z_F.jpg,/DU8709_688_D21Z_F.jpg,/DU8709_688_D21Z_B.jpg,,Enabled,Taxable Goods,"Catalog, Search",0.21,$9.99 ,some words,Ladies Pink and Khaki Cap,0,1,,,DU8709-D21Z-688-UNIT

My “ProductImport.php” file is located in the following folder on my linux box:
/www/app/code/core/Mage/Catalog/Model/Convert/Adapter

Here is my “ProductImport.php” file zipped up for reference: http://www.tegdesign.com/Productimport.zip

A QUICK EDIT...
I’ve noticed in the Database that when I manually click on a configurable product in the admin. Then in the left nav menu when I click on the link labled “Associated” - then click save. It changes the values for these tables in the configurable product.

Table: catalog_product_flat_1
has_options = 1

Table: catalog_product_entity
has_options = 1
requried_options = 1

Changes to 1 instead of the default of 0 in both tables.

 Signature 

Tegan Snyder
Web Developer
My Blog

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaybenfield
Jr. Member
 
Total Posts:  16
Joined:  2009-04-21
Washington DC
 

amartinez:

Thanks for your prompt response! In looking into it, at least at the time, it seemed like configurable products was the best way to go. From a user interface perspective it works great. That is, it’s presented to the user exactly how I want it. It’s just the assignment of pricing to the associated products that is killing me by mouse-click.

To back up a little bit… The store sells photographs (prints). There are two attributes: print_type & print_size. Each simple product has both. There are only a couple print_types (print, canvas, etc.) but a number of print_sizes (8x10, 10x14, etc.). In all, there’s 24 different simple products that get associated to the configurable product, each with a unique price.

The configurable product is the visible/unique photograph. Each of the configurable products is associated with all of the simple products, and the price is always the same. If I have a photograph of a duck or a photograph of an airplane, the print_type ‘canvas’ and print_size ‘10x14’ will always be $xx. There is no variation in price between configurable products - only in the simple ones.

That said, what I’m looking for is to automatically set the price (5x7’s always $10, 8x10’s always $20, etc.) after import *and* be able to update the price across all 8x10’s without clicking hundreds of times.

Thanks again for your help!

Jay

amartinez - 19 July 2009 11:49 PM

Can you use grouped products?

These configurable options are single or multiple?

Thanks by the cofee!



jaybenfield - 18 July 2009 04:48 PM
First of all amartinez, if you’re ever in the DC area I’ll buy you a cup of coffee! I just implemented your script on a store running 1.3.2.1. Thank you.

The missing piece of the puzzle at this point is adding prices to the associated products/options after import in an automated fashion. The store will have hundreds of configurable products, each associated to the same 25 simple products. After importing, I need to be able to push the pricing to all of the configurable products. And from an ongoing maintenance perspective, once the pricing is in place I need the ability to update pricing for a given simple product option ("change the price of XYZ on all configurable products from $10 to $15").

I’m digging through the forums right now, but if anyone has any pointers, a script, or some raw SQL that fits the bill, I would greatly appreciate it.

Thanks!
Jay

 
Magento Community Magento Community
Magento Community
Magento Community
 
freshman66
Jr. Member
 
Total Posts:  25
Joined:  2009-04-29
 

Hi all,

for all those who try to use the cron script on European (e.g. Germany) servers: make sure to put

setlocale(LC_ALL'en_EN');

at the beginning of the cron_import_products.php

The reason for this is that Magento uses the PHP “floatval” function to return the formatted decimal numbers. This function, however, returns the numbers formatted based on the current locale. This will cause “45.50” to be returned as “45,50”. This results is the following error:

“SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn’t match value count at row 1”

Maybe this saves someone a bit of time grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
819302 users|997 users currently online|519263 forum posts