Domanda

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.

È stato utile?

Soluzione

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top