you can just inject an instance of `Magento\Catalog\Model\ResourceModel\Product` in your class and use that one instead of `$product->getResource()`; /** * @var \Magento\Catalog\Model\ResourceModel\Product */ private $productResource; public function __construct( ... \Magento\Catalog\Model\ResourceModel\Product $productResource, .... ) { .... $this->productResource = $productResource; .... } And use this inside your methods $tablecolor = $productResource->getAttribute('xyz');