Some time we forgot to add weight to the product and its become an automatically of type virtual product.

I am trying to generate a product of a type "simple" in case we forgot to add weight ...

I would like to by-pass a condition where product type is set as "virtual".

I have done following workaround for this:

in the file : vendor/magento/module-catalog/Model/Product/TypeTransitionManager.php

under function processProduct() i have tried by commenting following line:


But it is not working.. How can we handle this programmatically?

  • For config child product?
    – Sohel Rana
    May 27, 2019 at 10:39
  • Yes How can we by-pass the condition o poduct type... and always create the product of type simple
    – 1990rk4
    May 27, 2019 at 10:43

1 Answer 1


Overwrite following class:


then modify getVariationMatrix method.

 * Get variation-matrix from request
 * @return array
protected function getVariationMatrix()
    $result = [];
    $configurableMatrix = $this->request->getParam('configurable-matrix-serialized', "[]");
    if (isset($configurableMatrix) && $configurableMatrix != "") {
        $configurableMatrix = json_decode($configurableMatrix, true);

        foreach ($configurableMatrix as $item) {
            if (isset($item['newProduct']) && $item['newProduct']) {
                $result[$item['variationKey']] = $this->mapData($item);

                if (isset($item['qty'])) {
                    $result[$item['variationKey']]['quantity_and_stock_status']['qty'] = $item['qty'];

                $result[$item['variationKey']]['product_has_weight'] = 1;
                $result[$item['variationKey']]['weight'] = 1;

    return $result;

Actually, you need to pass following params:

$result[$item['variationKey']]['product_has_weight'] = 1;
$result[$item['variationKey']]['weight'] = 1;
  • This approch is working for me... but I'll test some scenarios and will get back to you... Thanks for the quick reply..
    – 1990rk4
    May 27, 2019 at 11:47
  • Yes this is working in both case... when you add individual product... and add associates products. in both case it works well.. Thanks Rana... Actually when you add the associates products as swatch ... these associates products also becomes virtual products.. so this scenario also works..
    – 1990rk4
    May 27, 2019 at 11:52
  • Hi sohel, you are assigning the weight as 1 ... isn't it affected to shipping... means we are assigning the weight as 1... so a product which does not have weight will automatically assign weight as 1
    – 1990rk4
    May 28, 2019 at 10:03
  • just want to know whether it will affect during shipping or not
    – 1990rk4
    May 28, 2019 at 10:03
  • @rohan.katkar no, this function will use only for admin
    – Sohel Rana
    May 28, 2019 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.