1

How can I get the ID of product in Magento 2, in tempalte

vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml 

I copied it to my theme:

/app/design/frontend/xxx/ddd/Magento_Catalog/templates/product/price/amount/default.phtml

Thanks for the help! Martin

2

Template is using block:

\Magento\Framework\Pricing\Render\Amount

that has a method:

getSaleableItem()

that returns a SaleableInterface interface

that has a method:

getId()

so in your template you can do:

$block->getSaleableItem()->getId();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.