0

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.

2

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')
                    ->setStoreId(Mage::app()->getStore()->getId())
                    ->loadByRequestPath($vPath);

$iProductId = $oRewrite->getProductId();

https://stackoverflow.com/questions/9254789/magento-load-product-by-url

  • 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.