VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: joomlavod on July 16, 2013, 15:33:48 PM

Title: Products filters
Post by: joomlavod on July 16, 2013, 15:33:48 PM
Hi all! Please make a mechanism for filtering products like this http://www.hikashop.com/en/support/documentation/62-hikashop-developer-documentation.html#onBeforeProductListingLoad (http://www.hikashop.com/en/support/documentation/62-hikashop-developer-documentation.html#onBeforeProductListingLoad).
Title: Re: Products filters
Post by: Milbo on July 16, 2013, 16:02:45 PM
Is native there and there is also a trigger that you can use your own search plugin. and it is there since November 2010 or so.
Title: Re: Products filters
Post by: joomlavod on July 16, 2013, 16:34:23 PM
offtop
How this problem can be solved in virtuemart?
Title: Re: Products filters
Post by: balai on July 16, 2013, 17:05:50 PM
Why don't you try one of the existing filtering extensions
http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-products-search
Title: Re: Products filters
Post by: joomlavod on July 16, 2013, 17:30:55 PM
Quote from: balai on July 16, 2013, 17:05:50 PM
Why don't you try one of the existing filtering extensions
http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-products-search
Why pay for something you can do yourself? :)
PS. for this money I can buy Hika Buisnes)

offtop
What simplest method to organize the filter at the price?
Title: Re: Products filters
Post by: Milbo on July 16, 2013, 18:10:53 PM
http://virtuext.com/de/herunterladen/vx-extendedsearch-fuer-virtuemart-2-0.html for 15 euro hikashop business?

Of course you can write it yourself, IF you can. Even I can clearly write it myself, I would buy one, spares a lot money.
Title: Re: Products filters
Post by: balai on July 17, 2013, 12:34:52 PM

offtop
What simplest method to organize the filter at the price?
[/quote]

Its not simple at all. The final price usually is a result of multiple variants like the VAT percentage, Currency rates and discounts.
I assume that the hikashop's solution is just searching to the base price as it just joining 1 table.

Also if you want to create a professional shop without investing either 1 penny, i don't think that the result will be very satisfying.
Title: Re: Products filters
Post by: joomlavod on July 17, 2013, 15:12:59 PM
Quote from: Milbo on July 16, 2013, 18:10:53 PM
http://virtuext.com/de/herunterladen/vx-extendedsearch-fuer-virtuemart-2-0.html for 15 euro hikashop business?
Certainly not, but One Page Checkout (I already made it) is still necessary to me, it will cost 15 + 50 = 65 euro. :) It already at least Hika Essential which includes all these functions.
Let's not argue, an essence not in it.

Quote from: balai on July 17, 2013, 12:34:52 PM
I assume that the hikashop's solution is just searching to the base price as it just joining 1 table.

No, it is possible to connect any number of tables and conditions.

Quote from: balai on July 17, 2013, 12:34:52 PM
Also if you want to create a professional shop without investing either 1 penny, i don't think that the result will be very satisfying.
don't think that I am a miser, I work as the developer and to me don't give additional money for implementation.
I consider to pay from the pocket in case of a salary of 350 euro per month inappropriate.

Let speak on a subject, I only offered improving option for vm. If no, then no.
Title: Re: Products filters
Post by: joomlavod on July 22, 2013, 10:58:35 AM
Quote from: Milbo on July 16, 2013, 16:02:45 PM
Is native there and there is also a trigger that you can use your own search plugin. and it is there since November 2010 or so.

to add the same functionality to virtuemart enough add these code

// filter plugin trigger
JPluginHelper::importPlugin('search');
$dispatcher = JDispatcher::getInstance();
$plgDisplay = $dispatcher->trigger('plgVmProductListingLoad',array(&$select, &$joinedTables, &$whereString, &$groupBy, &$orderBy, &$filter_order_Dir, &$nbrReturnProducts) );


in the file:
administrator\components\com_virtuemart\models\product.php
befor exeSortSearchListQuery

$product_ids = $this->exeSortSearchListQuery (2, $select, $joinedTables, $whereString, $groupBy, $orderBy, $this->filter_order_Dir, $nbrReturnProducts);


then anyone can easily write a search/filter plugin like:

class plgSearchVmFilter extends JPlugin
{
    function plgVmProductListingLoad($select, $joinedTables, $whereString, $groupBy, $orderBy, $filter_order_Dir, $nbrReturnProducts)
    {
if (JRequest::getVar('filter',false))  {
$max_price = JRequest::getInt('price_max',0);
$min_price = JRequest::getInt('price_min',0);

// Price filter
if ($max_price) {
$joinedTables .= 'LEFT JOIN `#__virtuemart_product_prices` as z ON z.`virtuemart_product_id` = p.`virtuemart_product_id`';
$whereString .= 'AND z.`product_price` < '.$max_price.' AND z.`product_price` > '.$min_price;
}
}
    }
}

[/size]
please add this feature in new versions or write why it is not possible.
Title: Re: Products filters
Post by: Milbo on July 22, 2013, 15:40:04 PM
Because this trigger IS already there? as I said at begin. Native virtuemart is even searching for customfields, so I really wonder.


useCore = TRUE;
if ($this->searchplugin !== 0) {
//reset generic filters ! Why? the plugin can do it, if it wishes it.
// if ($this->keyword ==='') $where=array();
JPluginHelper::importPlugin ('vmcustom');
$dispatcher = JDispatcher::getInstance ();
$PluginJoinTables = array();
$ret = $dispatcher->trigger ('plgVmAddToSearch', array(&$where, &$PluginJoinTables, $this->searchplugin));
foreach ($ret as $r) {
if (!$r) {
$useCore = FALSE;
}
}
}

I think it is there since more than a year.
Title: Re: Products filters
Post by: joomlavod on July 23, 2013, 10:09:12 AM
Quote from: Milbo on July 22, 2013, 15:40:04 PM
Because this trigger IS already there? as I said at begin. Native virtuemart is even searching for customfields, so I really wonder.
I saw this triger, BUT, whether I can use this triger what to add conditions of a choice of products as in an example below?

        $joinedTables .= 'LEFT JOIN `#__virtuemart_product_prices` as z ON z.`virtuemart_product_id` = p.`virtuemart_product_id`';
$whereString .= 'AND z.`product_price` < '.$max_price.' AND z.`product_price` > '.$min_price;


I suspect that the response - No, if I am mistaken,please give an example of change of parameters of plgVmAddToSearch.