Filtering and searchind products using customfields

Started by tr, September 09, 2015, 20:31:04 PM

Previous topic - Next topic

tr

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

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

$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/