News:

Looking for documentation? Take a look on our wiki

Main Menu

[SOLVED] Get product_id/product object from module in product page

Started by EvanGR, June 02, 2022, 13:54:45 PM

Previous topic - Next topic

EvanGR

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

Jumbo!

<?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($productIdtruetruetrue1); // Get the product object.

$productModel->addImages($product);
?>

pinochico

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);
}


www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products