Author Topic: Filtering and searchind products using customfields  (Read 2723 times)

tr

  • Beginner
  • *
  • Posts: 1
  • A beginner
Filtering and searchind products using customfields
« on: September 09, 2015, 20:31:04 PM »
Hi everyone! In my opinion there is a small bug in administrator/components/com_virtuemart/models/product.php in VM 3.0.9.
I use this part of code
Code: [Select]
if (!empty($this->searchcustoms)) {
$joinCustom = TRUE;
foreach ($this->searchcustoms as $key => $searchcustom) {
$custom_search[] = '(pf.`virtuemart_custom_id`="' . (int)$key . '" and pf.`customfield_value` like "%' . $db->escape ($searchcustom, TRUE) . '%")';
}
$where[] = " ( " . implode (' OR ', $custom_search) . " ) ";
}
(304-310)
for filtering products in category view. For filtering products my plugin adding to current url params like .....&customfield[virtuemart_customfield_id]=customfield_value.
The variable $this->searchcustoms of VirtueMartModelProduct class receiving value of url option 'customfield[virtuemart_customfield_id]' using static method vRequest::getInt ('customfields') (186. $this->searchcustoms = vRequest::getInt ('customfields');). And the problem is in this static method, it receiving only integer value, if 'customfield[virtuemart_customfield_id]' has a string value, filter does not working. When I changed static method to vRequest::getVar ('customfields'), filter is work.
So, the question is: $this->searchcustoms = vRequest::getInt ('customfields') has error, and instead static method vRequest::getInt ('customfields') should be static method vRequest::getVar ('customfields'). Or it's my mistake, and i understand somethig wrong? 

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10663
  • VM4.0.232 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 4 on joomla 3
Re: Filtering and searchind products using customfields
« Reply #1 on: September 29, 2015, 11:15:59 AM »
$cid   = vRequest::getInt( 'cid', false );

if you use &cid=1, you get 1. If you use &cid[]=1 you get an array $cid[0]=>1
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/