Get Product Id On Product Page Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Get the product of review?Install Magento 2.3 without multisource inventoryClass MagentoCatalogModelProductAttributeBackendMedia does not existHow to get product image by product Id in magento2how to add bootstrap template to magento 2 pages and blocks without affecting my main theme (product page checkout page…etc)?Disable the Sidebar on Product View PageMagento 2 get product id from admin product edit pagePayment Method not showing information in admin order detailMagento 2 how to get product ID PriceHow to get current product in phtml without registry?

How to show element name in portuguese using elements package?

What causes the direction of lightning flashes?

How do I make this wiring inside cabinet safer? (Pic)

What is the escape velocity of a neutron particle (not neutron star)

Extracting terms with certain heads in a function

Did MS DOS itself ever use blinking text?

How would a mousetrap for use in space work?

What is the meaning of the simile “quick as silk”?

Why wasn't DOSKEY integrated with COMMAND.COM?

Why are there no cargo aircraft with "flying wing" design?

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

Compare a given version number in the form major.minor.build.patch and see if one is less than the other

Should I use a zero-interest credit card for a large one-time purchase?

Is it fair for a professor to grade us on the possession of past papers?

Is there any way for the UK Prime Minister to make a motion directly dependent on Government confidence?

How to answer "Have you ever been terminated?"

How to down pick a chord with skipped strings?

Significance of Cersei's obsession with elephants?

How to compare two different files line by line in unix?

Delete nth line from bottom

Why didn't Eitri join the fight?

Is there a kind of relay only consumes power when switching?

What is this building called? (It was built in 2002)

How to react to hostile behavior from a senior developer?



Get Product Id On Product Page



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Get the product of review?Install Magento 2.3 without multisource inventoryClass MagentoCatalogModelProductAttributeBackendMedia does not existHow to get product image by product Id in magento2how to add bootstrap template to magento 2 pages and blocks without affecting my main theme (product page checkout page…etc)?Disable the Sidebar on Product View PageMagento 2 get product id from admin product edit pagePayment Method not showing information in admin order detailMagento 2 how to get product ID PriceHow to get current product in phtml without registry?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















How can i get product id on product page without registry? Such as class registry is deprecated in magento 2.3










share|improve this question






















  • can you post your code? what di you try,? you can use ProductRepository

    – magefms
    Apr 14 at 2:01

















1















How can i get product id on product page without registry? Such as class registry is deprecated in magento 2.3










share|improve this question






















  • can you post your code? what di you try,? you can use ProductRepository

    – magefms
    Apr 14 at 2:01













1












1








1


1






How can i get product id on product page without registry? Such as class registry is deprecated in magento 2.3










share|improve this question














How can i get product id on product page without registry? Such as class registry is deprecated in magento 2.3







magento2 catalog magento2.3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 13 at 21:28









Петро ЧайківськийПетро Чайківський

10111




10111












  • can you post your code? what di you try,? you can use ProductRepository

    – magefms
    Apr 14 at 2:01

















  • can you post your code? what di you try,? you can use ProductRepository

    – magefms
    Apr 14 at 2:01
















can you post your code? what di you try,? you can use ProductRepository

– magefms
Apr 14 at 2:01





can you post your code? what di you try,? you can use ProductRepository

– magefms
Apr 14 at 2:01










2 Answers
2






active

oldest

votes


















1














You can use a view model.



Vinal kopp, write a blog where he has to create a custom registry but note that registry, not Magento generic registry like global variable.



  • The product is loaded by
    MagentoCatalogHelperProduct::initProduct. This method dispatches
    the event catalog_controller_product_init_after.

  • In the event observer RegisterCurrentProductObserver the product is
    set on a shared instance of the class
    VinaiKoppCurrentProductExampleRegistryCurrentProduct.


  • A new template block is added to the product detail page with layout
    XML. In the XML the block is configured to receive a view model, an
    instance of the class
    VinaiKoppCurrentProductExampleViewModelCurrentProductExampleViewModel
    .

  • The view model uses the shared RegistryCurrentProduct instance to
    retrieve the current product. This makes it a registry but without
    the downsides of the global core registry.

  • The template retrieves the view model from the block and renders the
    required product value

More detail at https://github.com/Vinai/module-current-product-example






share|improve this answer























  • It's not proper for me, but it is the best decision among the proposed.

    – Петро Чайківський
    Apr 14 at 10:16











  • Credit goes to vinai koop

    – Amit Bera
    Apr 14 at 10:18


















2














I have created a demo extension for you.



Link >> https://github.com/magento1993/ProductId



enter image description here






share|improve this answer








New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You are right, but, you created class and extends it from AbstractProduct that is using registry

    – Петро Чайківський
    Apr 14 at 10:12











  • extension updated plz check again, this time I am using product view block in the layout

    – Biren Patel
    Apr 14 at 16:33











  • Yes, but block you are using, use registry to get a product.

    – Петро Чайківський
    yesterday











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269998%2fget-product-id-on-product-page%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can use a view model.



Vinal kopp, write a blog where he has to create a custom registry but note that registry, not Magento generic registry like global variable.



  • The product is loaded by
    MagentoCatalogHelperProduct::initProduct. This method dispatches
    the event catalog_controller_product_init_after.

  • In the event observer RegisterCurrentProductObserver the product is
    set on a shared instance of the class
    VinaiKoppCurrentProductExampleRegistryCurrentProduct.


  • A new template block is added to the product detail page with layout
    XML. In the XML the block is configured to receive a view model, an
    instance of the class
    VinaiKoppCurrentProductExampleViewModelCurrentProductExampleViewModel
    .

  • The view model uses the shared RegistryCurrentProduct instance to
    retrieve the current product. This makes it a registry but without
    the downsides of the global core registry.

  • The template retrieves the view model from the block and renders the
    required product value

More detail at https://github.com/Vinai/module-current-product-example






share|improve this answer























  • It's not proper for me, but it is the best decision among the proposed.

    – Петро Чайківський
    Apr 14 at 10:16











  • Credit goes to vinai koop

    – Amit Bera
    Apr 14 at 10:18















1














You can use a view model.



Vinal kopp, write a blog where he has to create a custom registry but note that registry, not Magento generic registry like global variable.



  • The product is loaded by
    MagentoCatalogHelperProduct::initProduct. This method dispatches
    the event catalog_controller_product_init_after.

  • In the event observer RegisterCurrentProductObserver the product is
    set on a shared instance of the class
    VinaiKoppCurrentProductExampleRegistryCurrentProduct.


  • A new template block is added to the product detail page with layout
    XML. In the XML the block is configured to receive a view model, an
    instance of the class
    VinaiKoppCurrentProductExampleViewModelCurrentProductExampleViewModel
    .

  • The view model uses the shared RegistryCurrentProduct instance to
    retrieve the current product. This makes it a registry but without
    the downsides of the global core registry.

  • The template retrieves the view model from the block and renders the
    required product value

More detail at https://github.com/Vinai/module-current-product-example






share|improve this answer























  • It's not proper for me, but it is the best decision among the proposed.

    – Петро Чайківський
    Apr 14 at 10:16











  • Credit goes to vinai koop

    – Amit Bera
    Apr 14 at 10:18













1












1








1







You can use a view model.



Vinal kopp, write a blog where he has to create a custom registry but note that registry, not Magento generic registry like global variable.



  • The product is loaded by
    MagentoCatalogHelperProduct::initProduct. This method dispatches
    the event catalog_controller_product_init_after.

  • In the event observer RegisterCurrentProductObserver the product is
    set on a shared instance of the class
    VinaiKoppCurrentProductExampleRegistryCurrentProduct.


  • A new template block is added to the product detail page with layout
    XML. In the XML the block is configured to receive a view model, an
    instance of the class
    VinaiKoppCurrentProductExampleViewModelCurrentProductExampleViewModel
    .

  • The view model uses the shared RegistryCurrentProduct instance to
    retrieve the current product. This makes it a registry but without
    the downsides of the global core registry.

  • The template retrieves the view model from the block and renders the
    required product value

More detail at https://github.com/Vinai/module-current-product-example






share|improve this answer













You can use a view model.



Vinal kopp, write a blog where he has to create a custom registry but note that registry, not Magento generic registry like global variable.



  • The product is loaded by
    MagentoCatalogHelperProduct::initProduct. This method dispatches
    the event catalog_controller_product_init_after.

  • In the event observer RegisterCurrentProductObserver the product is
    set on a shared instance of the class
    VinaiKoppCurrentProductExampleRegistryCurrentProduct.


  • A new template block is added to the product detail page with layout
    XML. In the XML the block is configured to receive a view model, an
    instance of the class
    VinaiKoppCurrentProductExampleViewModelCurrentProductExampleViewModel
    .

  • The view model uses the shared RegistryCurrentProduct instance to
    retrieve the current product. This makes it a registry but without
    the downsides of the global core registry.

  • The template retrieves the view model from the block and renders the
    required product value

More detail at https://github.com/Vinai/module-current-product-example







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 14 at 4:32









Amit BeraAmit Bera

60.1k1678178




60.1k1678178












  • It's not proper for me, but it is the best decision among the proposed.

    – Петро Чайківський
    Apr 14 at 10:16











  • Credit goes to vinai koop

    – Amit Bera
    Apr 14 at 10:18

















  • It's not proper for me, but it is the best decision among the proposed.

    – Петро Чайківський
    Apr 14 at 10:16











  • Credit goes to vinai koop

    – Amit Bera
    Apr 14 at 10:18
















It's not proper for me, but it is the best decision among the proposed.

– Петро Чайківський
Apr 14 at 10:16





It's not proper for me, but it is the best decision among the proposed.

– Петро Чайківський
Apr 14 at 10:16













Credit goes to vinai koop

– Amit Bera
Apr 14 at 10:18





Credit goes to vinai koop

– Amit Bera
Apr 14 at 10:18













2














I have created a demo extension for you.



Link >> https://github.com/magento1993/ProductId



enter image description here






share|improve this answer








New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You are right, but, you created class and extends it from AbstractProduct that is using registry

    – Петро Чайківський
    Apr 14 at 10:12











  • extension updated plz check again, this time I am using product view block in the layout

    – Biren Patel
    Apr 14 at 16:33











  • Yes, but block you are using, use registry to get a product.

    – Петро Чайківський
    yesterday















2














I have created a demo extension for you.



Link >> https://github.com/magento1993/ProductId



enter image description here






share|improve this answer








New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You are right, but, you created class and extends it from AbstractProduct that is using registry

    – Петро Чайківський
    Apr 14 at 10:12











  • extension updated plz check again, this time I am using product view block in the layout

    – Biren Patel
    Apr 14 at 16:33











  • Yes, but block you are using, use registry to get a product.

    – Петро Чайківський
    yesterday













2












2








2







I have created a demo extension for you.



Link >> https://github.com/magento1993/ProductId



enter image description here






share|improve this answer








New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










I have created a demo extension for you.



Link >> https://github.com/magento1993/ProductId



enter image description here







share|improve this answer








New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Apr 14 at 6:39









Biren PatelBiren Patel

12110




12110




New contributor




Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Biren Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • You are right, but, you created class and extends it from AbstractProduct that is using registry

    – Петро Чайківський
    Apr 14 at 10:12











  • extension updated plz check again, this time I am using product view block in the layout

    – Biren Patel
    Apr 14 at 16:33











  • Yes, but block you are using, use registry to get a product.

    – Петро Чайківський
    yesterday

















  • You are right, but, you created class and extends it from AbstractProduct that is using registry

    – Петро Чайківський
    Apr 14 at 10:12











  • extension updated plz check again, this time I am using product view block in the layout

    – Biren Patel
    Apr 14 at 16:33











  • Yes, but block you are using, use registry to get a product.

    – Петро Чайківський
    yesterday
















You are right, but, you created class and extends it from AbstractProduct that is using registry

– Петро Чайківський
Apr 14 at 10:12





You are right, but, you created class and extends it from AbstractProduct that is using registry

– Петро Чайківський
Apr 14 at 10:12













extension updated plz check again, this time I am using product view block in the layout

– Biren Patel
Apr 14 at 16:33





extension updated plz check again, this time I am using product view block in the layout

– Biren Patel
Apr 14 at 16:33













Yes, but block you are using, use registry to get a product.

– Петро Чайківський
yesterday





Yes, but block you are using, use registry to get a product.

– Петро Чайківський
yesterday

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269998%2fget-product-id-on-product-page%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Sum ergo cogito? 1 nng

419 nièngy_Soadمي 19bal1.5o_g

Queiggey Chernihivv 9NnOo i Zw X QqKk LpB