Created
August 25, 2016 14:10
-
-
Save thagxt/6efbabd952c4b32e1661c167143dafb0 to your computer and use it in GitHub Desktop.
Magento 2 > product page > get Product URL, get Product Name and get Product ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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