Hello,
Simple question.
I am developing a custom module that goes in the Product page.
I need to retrieve the current product id (and product data object, which should be easy once I find the id)
I use SEF urls so I can't pick it up from there.
Any ideas?
Thanks
<?php
JLoader::register('VmConfig', JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();
$productId = JFactory::getApplication()->input->getInt('virtuemart_product_id', 0);
$productModel = VmModel::getModel('product');
$ratingModel = VmModel::getModel('ratings');
$productModel->withRating = $ratingModel->showRating($productId);
$product = $productModel->getProduct($productId, true, true, true, 1); // Get the product object.
$productModel->addImages($product);
?>
Try this - From our VM related product extended module + slideshow (https://www.minijoomla.org/extensions/virtuemart-extensions/related-products-extended-for-virtuemart):
if($current_view == "productdetails") {
$product_id = JRequest::getInt('virtuemart_product_id',0);
$productModel = VmModel::getModel('Product');
$front = true;
$onlyPublished = true;
$single = true;
$products = $productModel->getProducts($product_id, $front, $show_price, $onlyPublished, $single);
$productModel->addImages($products);
}
Thank you!