For some of our configured products (unfortunately), the PRODUCT_HAS_WEIGHT attribute has not been set to 1. Although, the products all have weight set (as a float), Magento still refuses to provide shipping calculation for these products.

I want to modify the PRODUCT_HAS_WEIGHT property for all products in the database. For that I want to access the MySQL database and issue a query that updates all the corresponding fields. Unfortunately, I was unsuccessful in identifying the attribute to update.

For example, to examine the weights, I would do the following:

  1. USE database
  2. SELECT * FROM eav_attribute where attribute_code LIKE '%weight%'
  3. SELECT * FROM catalog_product_entity_decimal where attribute_id = 82

In a similar fashion as in line (2), product has weight is not found.

I'd kindly ask the community, to help me find the related attribute to update for each product.

I'm using Magento CE 2.1.6.

  • Magento version ?
    – PЯINCƎ
    Jul 8, 2017 at 21:26
  • what is the magento version you are using Jul 8, 2017 at 21:27
  • I'm using Magento CE 2.1.6. Sorry for missing out this important detail. Thank you!
    – Dyin
    Jul 9, 2017 at 8:34

3 Answers 3


The attribute is not stored, is only use for meta purposes by the repo and it is basically a wrapper for the weight attribute within the method customizeWeightField() of class Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Modifying the product_has_weight you will change the product type; it defaults to 'Virtual' but it will get converted to "Download" if it has downloadable data, remember that 'has' is a magic method prefix, although hasWeight is overridden on product types virtual and downloadable for the purpose of locking down a false Boolean value. The value is not specifically stored, the state will remain in the form of the product type, see the TypeTransitionManager class and the plugin Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin\Downloadable, on configurable products it will be determined by the sum of the children state specified by the meta modifier.

  • when you say attribute, do you refer to the has weight? It is definitely stored somewhere, since it is switchable through the UI and for half of the products in the catalog, it prohibits shipping calculation at checkout. Do you know where can I find it and update through SQL?
    – Dyin
    Jul 11, 2017 at 13:40
  • I agree with his answer, and to me it seems the array key for example is modified when sent over the api (however I'm only guessing and will try to confirm now). Jul 11, 2017 at 14:55
  • Thanks! However, it is still not clear to me, how should I update this attribute? I mean I can confirm from the Magento Admin, that some configured products have weight set, for example 1.5 kilograms, but the has weight is disabled. The has weight can be enabled. The state is preserved.
    – Dyin
    Jul 11, 2017 at 15:17
  • I have modified the answer to explain how has weight is determined
    – Goku
    Jul 11, 2017 at 17:11
  • 1
    It just happen that I've found a related post on one of the threads: magento.stackexchange.com/questions/98898/…
    – Dyin
    Jul 11, 2017 at 18:41

I have found the constant for the property you are referring to, I haven't been using the API or repositories very much so I haven't seen the attribute before today:


The "weight" code attribute is mentioned in this file but only to update, not add.


Unfortunately I haven't got a Magento instance set up at the moment, but my first (perhaps stupid) thought is to check catalog/product eav attributes?

  • 1
    thanks. I've found the PRODUCT_HAS_WEIGHT as well, but could not figure out how it hits the database. Ultimately, I'm looking for a SQL UPDATE command to set has weight to true for all products in the catalog. I was unsuccessful in finding it in EAV attributes. Do you have any ideas in mind how to find it?
    – Dyin
    Jul 11, 2017 at 13:38
  • Weight is definitely in the eav_attribute table in Magento 2.1.4, I'm looking at it now. In my install it is attribute_id 82 however this could be different in yours? From my experience I've never set anything to "has weight" it's either virtual or not, and then either has a weight > 0 or weight === 0... Forgive my inexperience. Jul 11, 2017 at 13:48
  • PRODUCT_HAS_WEIGHT does not appear in a search of all files in 2.1.4 whatsoever. Jul 11, 2017 at 14:56

I want to modify the PRODUCT_HAS_WEIGHT property for all products in the database. For that I want to access the MySQL database and issue a query that updates all the corresponding fields

As I needed this today and didn't find the accepted answer actually provided this, I have prepared the following one liner tested with Magento 2.3.3:

UPDATE catalog_product_entity cpe
SET type_id = IF(
    (SELECT COUNT(1) FROM catalog_product_relation WHERE parent_id = cpe.entity_id), 
WHERE type_id = 'virtual'

Note I am testing if there are child products so as to correctly identify configurable products, else their child products would be orphaned.

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.