Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top