0

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?

0

1 Answer 1

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

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

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