- Beranda
- Komunitas
- Tech
- Website, Webmaster, Webdeveloper
Get product id and sku in template file
![daniel8115](https://s.kaskus.id/user/avatar/2018/03/20/default.png)
![Avatar border](https://s.kaskus.id/images/avatarborder/1.gif)
TS
daniel8115
Get product id and sku in template file
Use the below script to get the product by id and SKU in the template file.
$id = YOUR_PRODUCT_ID;
$sku = 'YOUR_PRODUCT_SKU';
$_product = $block->getProductById($id);
$_product = $block->getProductBySku($sku);
echo $_product->getEntityId();
echo '<br />';
echo $_product->getName();
If you have any queries about the article or any questions in general, use the comment section below!
End Step 2 Get product id and SKU in template file in Magento 2
$id = YOUR_PRODUCT_ID;
$sku = 'YOUR_PRODUCT_SKU';
$_product = $block->getProductById($id);
$_product = $block->getProductBySku($sku);
echo $_product->getEntityId();
echo '<br />';
echo $_product->getName();
If you have any queries about the article or any questions in general, use the comment section below!
End Step 2 Get product id and SKU in template file in Magento 2
0
1.5K
0
![Guest](https://s.kaskus.id/user/avatar/default.png)
![Avatar border](https://s.kaskus.id/images/avatarborder/1.gif)
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
![Guest](https://s.kaskus.id/user/avatar/default.png)
![Avatar border](https://s.kaskus.id/images/avatarborder/1.gif)
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan