VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: mailblade on September 20, 2017, 09:16:37 AM

Title: Multiple condition WHERE clause for products?
Post by: mailblade on September 20, 2017, 09:16:37 AM
SOLVED
Other thread which has the correct answer: https://forum.virtuemart.net/index.php?topic=138437.0

Hello.

Is there any way to have a Query display a result based on the value of the $product_id and a specific $customfield_id?

Example code, which is definitely wrong I assume:
$db = JFactory::getDBO();
     $db->setQuery("SELECT customfield_value FROM jos_virtuemart_product_customfields WHERE virtuemart_customfields_id="5" AND WHERE virtuemart_product_id=".$product->virtuemart_product_id.";");
     $db->query();
     $result = $db->loadResult();
echo ($result)


So this query needs to display the result where "virtuemart_customfield_id" = 5 AND where the "product_id" = the associated product.

Thanks for reading.
Title: Re: Multiple condition WHERE clause for products?
Post by: Milbo on September 20, 2017, 21:27:42 PM
There is a full function for that. check the view.html.php of the productdetails view.
Title: Re: Multiple condition WHERE clause for products?
Post by: mailblade on September 21, 2017, 06:44:16 AM
Thank you Milbo I will have a look  :)
Title: Re: Multiple condition WHERE clause for products?
Post by: mailblade on September 21, 2017, 09:44:46 AM
Just a heads up: This same issue has been solved on another thread which I created :)

https://forum.virtuemart.net/index.php?topic=138437.0

Solved