TL; DR: Is there any reason why the simple products associated to a configurable product have to be in the same attribute set as the configurable product itself? I mean, is there any technical reason? I know the "common sense" reason. If you sell a pair of shoes then all the versions depending on color and size have to be shoes also.
Long version: I had a task to "merge" some configurable products. I mean from 2 or more to make only one. I didn't want to do them manually because of the amount of products and I didn't want to go through $product->load(..)->set...()->save()
because of the amount of time it took to run the script. So I short-circuited the process because I was sure that none of the simple products overlapped. There was a unique combination of size and color. I did this:
Mage::getResourceSingleton('catalog/product_type_configurable')
->saveProducts($mainConfigrableProduct, $simpleProductIds);
where $simpleProductIds
is an array of all simple product ids associated all to the configurable products that need to be merged.
This worked perfectly for most of the products, but there were a few that has issues.
If I called
$productIds = $product->getTypeInstance()->getUsedProductIds()
I would get all the simple product ids, but in the backend only a few of them appeared. After digging for some time I found out that the only ones that were shown were the ones in the same attribute set as the configurable product. The other attribute set is very similar to the first one, just some minor differences but it contains the configurable attributes (size and color).
And now the strange thing. In the frontend I expected to see either all the products ($productIds in the code above) or only the products in the same attribute set. Well there was something between.
- 20 associated product ids - 5 sizes, 4 colors
- 10 associated products in the backend - 5 sizes, 2 colors - the other 2 colors (10 products) were in a different attribute set
- 15 combinations in the frontend - 5 sizes 3 colors (???)
I was able to solve the issue by changing the attribute set for the products that didn't appear, but I'm still puzzled.
Note: Don't try this at home. Or you can try it at home but not on a live server.