I have a system which has a set of products of three "types":
- Simple products without associated products;
- Group products;
- Simple products, which are associated to group products.
I need to:
- convert type 1 into bundle product and create associated simple product.
- convert type 2 into bundle product and keep it's associated simple products.
I know already about this extension http://www.magentocommerce.com/magento-connect/displaze-change-product-type.html but seems be capable of only converting
simple -> bundle, while I also need
grouped -> bundle conversion.
Since it is not possible to change product types with
avs-fastsimpleimport, I removed anything about it from the question.
/* * preparing list of simple products, * which are not associated with any other * complex products (group, bundle, configurable and so on) */ SET @simpleSkuList = ( SELECT GROUP_CONCAT(sku) FROM catalog_product_entity WHERE type_id = 'simple' AND LENGTH(sku) = 8 AND( entity_id NOT IN( SELECT DISTINCT (product_id) FROM catalog_product_super_link /* associated product ids of configurable */ UNION SELECT DISTINCT (linked_product_id) FROM catalog_product_link /* associated product ids of grouped */ UNION SELECT DISTINCT (child_id) FROM catalog_product_relation /* associated product ids of bundled and grouped */ ) ) GROUP BY type_id ); /* changing simple products type to be 'bundle' products */ UPDATE catalog_product_entity SET type_id = 'bundle' WHERE find_in_set(sku, @simpleSkuList);
And the question now sound like, does anybody think that this MySQL query can be improved somehow?