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

Configurable Products? 
 
webbuddy
Member
 
Total Posts:  41
Joined:  2008-06-05
Australia
 
Samith_nzl - 01 September 2008 12:47 PM

Hey webbuddy,

I have done an export to csv of 5 products I had in my catalog, 1 being a configurable product made form 2 simple products. The other two just standard simple products.
All worked fine in front and backed ( in stock, can add to cart etc ).

I then ran an export all products, ( to csv ), I then deleted all 5 products and ran the “import all products”. It imported all my 5 products however my configurable product was not associated to my 2 simple products. I looked in the csv file and I don’t see how it links my configurable product to my simple products.....

Any thoughts or help ?

Cheers,
Samith_nzl

After you have imported your Configurable/Simple Products. you need to go into Admin>Catalog>Products and edit your Configurable Products at the “Associated Products” Tab (right at the bottom) and select the simple products associated with your configurable one.  All of this is covered in one o the video tutorials as well.  I dont know that there is an easier way to associate the two in a csv or XML.  I have done all my associating manually as above.

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

Hey,

Thanks for your help, associating them manually does work, but I am really after doing it all from an import. I am trying to sort out an art site, where each painting has the possibility of a couple of different sizes, but also has the option of 7 different matt colours and 2 different frame colours, this is for 100+ products.

I thought it should definitely been some way to the configured product associations from direct from the import :S

Anyways, thanks for your help, and if you know of any way to try and get configs setup direct from the import let me know!

Cheers
Samith_nzl

 
Magento Community Magento Community
Magento Community
Magento Community
 
webbuddy
Member
 
Total Posts:  41
Joined:  2008-06-05
Australia
 

@Samith
Welcome to my world smile

I am currently trying to figure out the best way to present one particular furniture line which has 4 layers of options plus a choice of 8 colours.  Its a conundrum just trying to imagine the smartest way to do it.  Using Excel to create xml files to upload is easy enough but for what is basically a simple choice of 5 base products I can see me creating literally hundreds of simple products to cover all the possibilities.

I am going to check out the alternate of custom options and see if I can assign a price effect to them so a simple drop down box or rdion button can specify an option and subsequently impact on the price.

Good Luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
webbuddy
Member
 
Total Posts:  41
Joined:  2008-06-05
Australia
 
Samith_nzl - 01 September 2008 02:40 PM

Hey,

Thanks for your help, associating them manually does work, but I am really after doing it all from an import. I am trying to sort out an art site, where each painting has the possibility of a couple of different sizes, but also has the option of 7 different matt colours and 2 different frame colours, this is for 100+ products.

I thought it should definitely been some way to the configured product associations from direct from the import :S

Anyways, thanks for your help, and if you know of any way to try and get configs setup direct from the import let me know!

Cheers
Samith_nzl

OK I have just rediscovered Custom options (available since v1.1 release) Here you can more easily add options that effect price.  I had seen this on release then promptly forgot about it.  :(

Check this video on custom options (no sound)

Hope this helps

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

Hey webbuddy,

Thanks for the link, Custom options is pretty sweet as it allows for the required attributes, pre-product instead of loads of simple products for one configurable product, but I can’t get it to export the fields associated with the custom options when exporting the products ( so I can’t make up the products for my import file :| ).

This is crazy, I have been searching these forums & google so much, that I just end up seeing my own posts at the end of promising threads :S

Let me know if you find anything, and I will do the same.

Cheers,
Samith_nzl

 
Magento Community Magento Community
Magento Community
Magento Community
 
webbuddy
Member
 
Total Posts:  41
Joined:  2008-06-05
Australia
 

Hey Samith,

I understand that you want to try and import these options, as opposed to manually creating them.  Maybe create a few against a few products and then search through your database (phpmyadmin) and see if you can find where they are at.  I am intrigued that they require a value in field sku, so maybe when you create them they are created in the products table with the rest.

For my part I only have a few products requiring more complex custom options and so I will just create manually.  The rest of my stock is Config/Simple combos using xml imports.

Good Luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 
Samith_nzl - 01 September 2008 06:00 PM

Hey webbuddy,

Thanks for the link, Custom options is pretty sweet as it allows for the required attributes, pre-product instead of loads of simple products for one configurable product, but I can’t get it to export the fields associated with the custom options when exporting the products ( so I can’t make up the products for my import file :| ).

This is crazy, I have been searching these forums & google so much, that I just end up seeing my own posts at the end of promising threads :S
l

If you only have a few products to do, just create one product and add the custom options, save it, then hit the Duplicate button. You won’t have to re-enter all the options that way.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 

OK, I’ve been struggling with the issue of importing configurable products for way too long. It shouldn’t be this difficult.
I made some code that does most of it but I’m running into a brick wall on the attributes.

What I did is copy the XML from the standard import profile, create an advanced profile, paste in the XML, and change one little line where it tells it what adapter to run.

<var name="adapter">catalog/convert_adapter_product</var>
becomes
<var name="adapter">catalog/convert_adapter_productwithlinks</var>

Then, I use the same name for my new import script. This means that in app/code/core/Mage/Catalog/Model/Convert/Adapter you will find Product.php. Make a copy of it and rename it to whatever you called it in the XML, in my case it’s Productwithlinks.php which I’ve attached to this post. I didn’t want to put it in the core, but I couldn’t figure out how to tell it to look anywhere else, since it’s not a module.

In the php file, change the class inheritance so it inherits from the one we copied, delete everything except the saveRow function, and add a little code to handle the configurable product stuff. That looks like this

class Mage_Catalog_Model_Convert_Adapter_Productwithlinks
    
extends Mage_Catalog_Model_Convert_Adapter_Product

and I added some code like this for each kind of product link in the middle of the function:

if (isset($importData['upsell'])) {
     $linkIds 
$this->skusToIds($importData['upsell']$product);
     if (!empty(
$linkIds)) {
        $product
->setUpSellLinkData($linkIds);
     
}
  }

and two little functions for skusToIds and userCSVDataAsArray.

Now what this does is look for import data columns of skus for related, upsell, crosssell, grouped, and associated. It links them all up correctly, even the configurable product links. The other new import column called config_attributes should contain the name of the attribute to use for the configurable product, for example color. Not the ID, but the name. The above code looks up the ID. That part is working. It even sets the attribute IDs into the product correctly.  The brick wall comes up when I go to save, the attributes are not found and so not saved.

So what I thought was happening was the configurable product was not getting called to do its part of the save. It turns out that the configurable product does not inherit from the Product class. Instead it is a separate Type class and just affects its “Product” by calling functions on it (not of it, but on it). So it looks to me like the Product that the attribute data is getting stored in is different from the Product that the configurable Type instance is looking at, but I can not see where to change it.  I tried setting it with

$product->getTypeInstance()->setProduct($product);
but it did not work. Every object I tried in there gave some sort of error.

I could easily hack some code in there for the attributes (just code a mysql command to stuff the values in the table), but if you call the functions that exist, they handle deleting and updating and inserting for you. So I’d prefer to get it working the right way. Actually, that may not be true for the attributes because of how the admin panel is designed—as in you can’t change the attributes once you’ve selected them. But the links fields work right. They automatically adjust for insert and delete.

I didn’t try to do the custom options fields. There are so many things to enter, you’d need a complicated field to enter them.
The columns I added all take multiple values in one column. So you can put sku1,sku2,sku3 in any of the new columns. I wanted to have it allow wildcards too, but the resource function it is calling uses = instead of LIKE. I didn’t go down that path to change it, but it should be pretty easy. (another hack to the core or just code the query right there)

Does anyone have any ideas how to get that last little bit to work? I’m worn out. This is the worst looking code I’ve seen in years. It’s a developer’s nightmare. The last time I was on a project with code like this, I changed companies so I could work on a different project. Seriously. It was the US Postal Service Point of Sale project about 12 years ago.

File Attachments
Productwithlinks.php  (File Size: 11KB - Downloads: 405)
 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 

I woke up with another idea to try and with a little trial and error, I got a little bit more to work.

Now the attributes get saved (hurray!), but I can’t seem to make them required so they don’t show up on the front end. I’ve tried many combinations of the flags for options,required options,configurable attributes etc. but the code is looking at whether there is price data, so I don’t know how it works in the admin panel.

So this version has a little more functionality than the previous version.
Say something if you know how to get the product to have the has_options field set on (besides just a database query).

Update: I need to modify something with the attributes. It is always adding, even if it’s already there, so after running a bunch of tests in a row I looked at my product. It had the same attribute listed about 10 times.
So be aware that this version is always adding the configurable attribute. Only import your product once with the config_attribute column set.

File Attachments
Productwithlinks.php  (File Size: 12KB - Downloads: 404)
 
Magento Community Magento Community
Magento Community
Magento Community
 
dp7777
Jr. Member
 
Total Posts:  30
Joined:  2008-08-18
 

joyously,

I’ve been trying to work through your intrustions and i’m a little stuck.

I want to associate some simple products with a configurable so i have done the following:

~exported a csv via “system -> import/export -> profiles -> export all products”
~edited the csv to include two extra columns (associated and config_attributes) and added ths SKU for the configurable product in all the simple product associated rows and the attribute name in the config_attribute column.
~created C:\inetpub\wwwroot\proverified.net\citadelpolytunnels\app\code\core\Mage\Catalog\Model\Convert\Adapter\Productwithlinks.php but only inclded the “associated and configurable” parts of your code
~created an advance profile which is a copy of the xml from “import all products” and altered the adapter line to include “catalog/convert_adapter_productwithlinks”

Now when i try to run the advanced profile i get an error saying “error write batch_33.tmp” to get round this i have created a number of empty files in var/tmp/batch_XX.tmp and the import screen now runs without error but im not sure where the csv is called from. in the import all products profile you have to specify the file before running the import.

Any help would be massively appreciated.

Many thanks

DP

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 

@dp7777 I never had any problem with the import not creating a tmp file. It could be a permissions problem.
The csv file is specified in that xml that you copied. Mine looks like this

<var name="filename"><![CDATA[import_test_products.csv]]></var>

Other than that I see 2 things that might be wrong.

One is that you seem to have the concept of configurable and simple backwards. On the import it’s just like in the admin panel. To create a configurable product you specify the configurable atrributes and the associated products.  To create a simple product, you just create a product.  Same with the import data, so the config_attributes column would be empty for simple products and filled in for configurable (actually it’s only examined for configurable products). This goes for the associated column as well. The simple products have no associated, so that column is empty. The configurable products associated column would contain the SKUs of the simple products (separate them with commas).

The second thing might affect you if you try to do it multiple times. In my code, I commented out the check for whether the product exists for the section that deals with the product type and attribute set. This way you can change an existing product from simple to configurable and/or a different attribute set.  So if your product exists from one attempt but it’s the wrong type, if you don’t have that part commented the type will not be affected.  The other half of this is that if you run it more than once with the configurable attributes being specified, they will be added each time, as I mentioned in my previous post.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dp7777
Jr. Member
 
Total Posts:  30
Joined:  2008-08-18
 

Thanks for the advice.

I worked out that im an idiot. i had the “imprt all products” profile set to interactice so i couldnt specify the file name. doh!

i now have the set of SKU’s for each simple product in the associated column (comma seperated) of the configurable product and both config attribute names in the configurable product config_attributes column (comma seperated).
(the config attribue names used are the same of the column name for the the attribue in the exported csv)

This apprears to all work but… when i go into the front end i am not seeing any assciated products and in the database “catalog_product_super_link” is empty.

Am i right in thinking this table holds the relationships between products?

(i had already picked up on the need to clear out the products in between runs)

Thank you for your patience.

dp

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 
dp7777 - 23 September 2008 06:05 AM

This apprears to all work but… when i go into the front end i am not seeing any assciated products and in the database “catalog_product_super_link” is empty.

Am i right in thinking this table holds the relationships between products?

When you say it works, what do you mean?
The front end will probably still have the unresolved issue of not showing the dropdown for the attributes because it’s not set to required (has_options is not set). I’m having no luck figuring that one out. If you set it in the database or from the admin(just edit and save the product), it will show on the front end.

The code I provided fills in the super link, which does hold the associated products relationship. If yours is empty, put some print statements in the code and see which part it’s not executing. (your stuff will get printed, but it will cause Magento to think there is an error --just ignore that)
You have to have the config_attributes in catalog_product_super_attribute and then the relationship in catalog_product_super_link.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dp7777
Jr. Member
 
Total Posts:  30
Joined:  2008-08-18
 

I meant the import is working. ie the products are appearing but they are not appearing in the “super product attributes configuration” area of the “manage products/associated products” area.

I’ll have a go at adding the print statements and see whats going wrong.

Thanks again for all your help!

dp

 
Magento Community Magento Community
Magento Community
Magento Community
 
dp7777
Jr. Member
 
Total Posts:  30
Joined:  2008-08-18
 

One last question. I’m using 1.1.6 as far as you know should this still work?

Still tearing my hair out going round and round.

I just cant get anything to appear in the “super product attributes configuration” area even if i populate the catalog_product_super_link table it clears itself when i go back in to the admin pages.

Any ideas?

thanks

dp

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