I’ve problem to get current product id from custom block displayed on product page. Here my code :
class TestBlock extends BlockBase { public function build() { $product = Drupal::routeMatch()->getParameter('node'); $productid = $product->product_id(); return array( '#markup' => $this->t('Product ID : ') . '<h2>' . $productid . '</h2>', ); } }
Do you have any idea to get the current ID from product ?
Thank you for your help.