I want to check whether a certain product is of type 'grouped' or something else. And, i need to do this without loading the whole product.

Now for other attributes the code below seems to work perfectly well.

$productResource = $this->objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Action');
$uom = $productResource->getAttributeRawValue($productId, 'uom', $storeId);

But somehow this fails:

$type = $productResource->getAttributeRawValue($productId, 'type_id', $storeId);

$type is always empty.

1 Answer 1


type_id is not an eav attribute. without gathering the whole model, you can do it through raw SQL query(it is the fastest solution I guess)

SELECT type_id FROM catalog_product_entity WHERE entity_id=Your_Product_Id
  • Ah, that sounds like a reason for not being able to retrieve it via the getAttributeRawValue
    – Tys
    Commented Oct 11, 2018 at 13:19
  • The thing is, im handling many many products, and just some of them are grouped. And, if so, i have to do something with the underlying childs. So i was really hoping to find a solution that doesn't involve a database call for every product.
    – Tys
    Commented Oct 11, 2018 at 13:20
  • You can do only one query like SELECT entity_id FROM catalog_product_entity WHERE type_id="grouped" just save result of this query and compare products ids in PHP. If product id is in result(this product is grouped) then do some logic Commented Oct 12, 2018 at 9:03
  • I'll go for the one query setup. And next, i'm going to create an additional attribute which i'm going to set to true, if an item is a grouped item.
    – Tys
    Commented Oct 16, 2018 at 10:44

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.