cancel
Showing results for 
Search instead for 
Did you mean: 

Simple to configurable product convert

Simple to configurable product convert

I'm using Magento 2.2 and I've got a situation where I have created a load of configurable products without setting a weight, so the generated products have been saved as 'virtual' products as expected.

 

However, since these have been created, I realize that a weight needs to be set on configurable products children in order to calculate shipping costs.

 

So, with that in mind I went through and set a weight on all the configurable products, thinking that would set a weight for all it's children. But this is not the case.

 

The problem I now have is that I have to manually set the weights of all the virtual products (which I know will turn them to simple products - and theres a lot)

 

So i'm looking at writing a script that will

  1. Get all the virtual products that have a parent
  2. Get the parent's weight value
  3. Set the virtual products weight to the same as it's parent.

I've tried looking at doing this on a database level by looking in the tables 'catalog_product_entity', 'catalog_product_entity_decmial' and matching up the weight attribute id, etc.. and although script worked, in the sense that it updated the database. It didn't work in what it shows in the admin area, and on the website...

 

I noticed that there is a 'catalog_product_flat_1' table, but I feel like I;m going into uncharted territory... and that I should go back to route one, and update the database using the Magento code/framework...

 

I'm hoping someone can point me in the right direction on how I should go about this.

3 REPLIES 3

Re: Simple to configurable product convert

@neilcarpenter If you have weight ready then use Magento import functionality to update the weight as products already exit so you only need to set SKU and Weight of associated products.

What you've done is correct flow, fetch associated products and update weight.

Have you reindex indexer? clean cache as well after this operation.


Cheers!

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

Re: Simple to configurable product convert

Hi @GauravMehta04 thanks for getting back to me on this.

 

An update on my issue as i'm in a bit of a different position now.

 

All the virtual products that were generated by the configurable product have all got a weight value set, but because they are still classed as virtual products their weight value isn't being used when calculating shipping.

 

So now I need to convert all the generated virtual products to simple products...

 

If I update the `type_id` column on the `catalog_product_entity` table in the database and then run 'indexer:reindex' should that apply my changes into the 'catalog_product_flat_1' table in the database?

Re: Simple to configurable product convert

Hi,

I would not recommend to make changes in database directly (if you already did, hope you have backup). The reason is that there you will do changes for all of our products, not those you just created. Also db relations are complex and doing changes in one table you make break its relation with other and have unexpected outcomes. 

For one-time change I'd rather use extension to change product type, like free version of this one (works with M1 and M2).