Skip to content

Instantly share code, notes, and snippets.

@Alexander-Pop
Forked from thagxt/get-product-info.php
Last active September 5, 2019 15:59
Show Gist options
  • Save Alexander-Pop/8b35f7e16e92138e1cea936eb017de9f to your computer and use it in GitHub Desktop.
Save Alexander-Pop/8b35f7e16e92138e1cea936eb017de9f to your computer and use it in GitHub Desktop.
[get Product URL, Name and ID] get Product URL, get Product Name and get Product ID #magento2
<?php
// get current page URL
$URL = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
// get current product name & ID
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Framework\Registry')->registry('current_product'); //get current product
$id = $product->getId();
$title = $product->getName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment