Reputation: 65
For example, here is url
http://www.tiffosi.com/mulher/camisas-e-tunicas/blusa-l-s-93368.html.
There are several simple products. How can I get the actual simple product ID, from this url?
Magento 1.8
Upvotes: 0
Views: 1484
Reputation: 3294
First use the URL rewrite model to find the route which matches your product:
$vPath = 'http://www.tiffosi.com/mulher/camisas-e-tunicas/blusa-l-s-93368.html';
$oRewrite = Mage::getModel('core/url_rewrite')
->setStoreId(Mage::app()->getStore()->getId())
->loadByRequestPath($vPath);
Then you can call getProductId() on the route to locate the produc's id:
$iProductId = $oRewrite->getProductId();
Finally if you require the product model object itself it's then a simple matter to call:
$oProduct = Mage::getModel('catalog/product')->load($iProductId);
Upvotes: 1