Author Topic: Multiple condition WHERE clause for products?  (Read 736 times)

mailblade

  • Jr. Member
  • **
  • Posts: 109
  • A beginner
Multiple condition WHERE clause for products?
« 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:
Code: [Select]
$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.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10040
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Multiple condition WHERE clause for products?
« Reply #1 on: September 20, 2017, 21:27:42 pm »
There is a full function for that. check the view.html.php of the productdetails view.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

mailblade

  • Jr. Member
  • **
  • Posts: 109
  • A beginner
Re: Multiple condition WHERE clause for products?
« Reply #2 on: September 21, 2017, 06:44:16 am »
Thank you Milbo I will have a look  :)

mailblade

  • Jr. Member
  • **
  • Posts: 109
  • A beginner
Re: Multiple condition WHERE clause for products?
« Reply #3 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