just facing a new challenge...I can't solve

I'd like to get the ID of a product (CG Products module) but I know only the name.
Do you know how to do it ?
Thank you in advance !
Have a nice day

In the admin yes....it's that easy !Dr.CSS wrote:Isn't it the first thing on the left next to the products name..?
Code: Select all
$name = $params['name'];
$assign = $params['assign'];
$product_id = '';
$db = cmsms()->GetDb();
$query = 'SELECT id FROM '.cms_db_prefix().'module_products WHERE product_name= ?';
$row = $db->GetRow($query,array($name));
if(!is_array($product)) {
$product_id = $row['id'];
}
$smarty->assign($assign, $product_id);
Code: Select all
{get_product_id name='Mr. Potato Head' assign='product_id'}
The ID is: {$product_id}