This question already has an answer here:

I'm not on a product page (custom module) and I have the URL of a product page. Is it possible to get the product ID from a URL?

I checked Mage::getUrl but that seem to generate URLs - I need it the other way round. Is there a possibility to do that? Via the rewrite table?

marked as duplicate by sv3n, Jai, Manoj Deswal, Priyank, Piyush Mar 31 '18 at 4:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


you can get the product ID as the following example, since you already have the path included the URL.

$oRewrite = Mage::getModel('core/url_rewrite')

$iProductId = $oRewrite->getProductId();


  • Awesome! Thank you, that worked fine for me. – Chris Nov 12 '14 at 3:49
  • Glad it helped. – Rabea Nov 12 '14 at 3:56

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