VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Topic started by: Pisu on December 22, 2006, 11:10:06 am

Title: Filter product category by manufacturer
Post by: Pisu on December 22, 2006, 11:10:06 am
I noticed that in shop browsing, you can browse by category OR by manufacturer (with appropriate module), but not each together. An example: I have a category "Notebook" with various manufacturer (Asus, Toshiba, ...), when I go to Notebook category, I can't filter for view only notebooks of Asus. This was a really need for me, so I made an hack for this.

I'm attaching the pages I hacked: shop.browse.php and shop_browse_queries.php.

I'll try to explain what I made.

1- added SELECT box with list of manuf for that category, in top of the shop browse page; code added just after the sort objects, before hidden fields (line 217 in original shop.browse.php file) (tnx to manufacturer list module):
Code: [Select]
$query  = "SELECT distinct a.manufacturer_id,a.mf_name FROM #__{vm}_manufacturer AS a ";
if (!empty( $category_id ) ) {
    $query .= ", #__{vm}_product_category_xref AS d, "
    . " #__{vm}_product AS b, "
    . " #__{vm}_product_mf_xref AS c "
    . " WHERE d.category_id='$category_id'"
    . " AND d.product_id = b.product_id "
    . " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";
}
$query .= "ORDER BY mf_name ASC";
$db = new ps_DB;
$db->query( $query );

$res = $db->record;

?>
        <select class="inputbox" name="manufacturer_id" onchange="order.submit()">
            <option value=""><?php echo _CMN_SELECT ?></option>
        <?php  
foreach ($res as $manufacturer) { 
$selected '';
if( @$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id ) {
$selected 'selected="selected"';      
}
echo "<option value=\"".$manufacturer->manufacturer_id ."\" $selected>"$manufacturer->mf_name ."</option>\n";


        
?>

        </select>

2- commented "manufacturer_id" hidden field (ok you can delete it):
Code: [Select]
<!--<input type="hidden" name="manufacturer_id" value="<?php echo $manufacturer_id ?>" />-->
3- changed $url building, to not add duplicated manufacturer_id variabile (around line 330):
Code: [Select]
        $url = $sess->url( $mm_action_url."index.php?page=shop.product_details&flypage=$flypage&product_id=" . $db_browse->f("product_id") . "&category_id=" . $db_browse->f("category_id"));
if (!empty($manufacturer_id) && $manufacturer_id<>0) {
$url .= "&manufacturer_id=" . $manufacturer_id;
}

4- now let's open shop_browse_queries.php; first problem was that if manufacturer_id was passed, category filter is ignored; so I changed IF condition in line 181:
Code: [Select]
elseif (empty($manufacturer_id) || !empty($category_id)) {
5- in following lines, made a condition, if manufacturer_id is passed, you have to load also vm_product_mf_xref table in FROM of the queries (I decided to not load it always to improve general performances):
Code: [Select]
/*** GET ALL PUBLISHED PRODUCTS ***/
$list  = "SELECT DISTINCT $fieldnames FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$count  = "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
if ($manufacturer_id) {
$list  = "SELECT DISTINCT $fieldnames FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`,`#__{vm}_product_mf_xref`) ";
$count  = "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`,`#__{vm}_product_mf_xref`) ";
}

6- around line 208, I added the effective WHERE condition for manufacturer:
Code: [Select]
if ($manufacturer_id) {
$q  .= "\n AND `#__{vm}_product_mf_xref`.manufacturer_id='".$manufacturer_id."' AND #__{vm}_product_mf_xref.product_id=#__{vm}_product.product_id ";
}

Hope this help... for me is very useful!!!!! Comments are appreciated!

Update 11/09/2007: files updated to VirtueMart 1.0.12

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: nhcompi on December 22, 2006, 22:37:46 pm
Hi Pisu!

That's great! I have search for this a long time!

Many Thanks!
Title: Re: Filter product category by manufacturer
Post by: Pisu on January 02, 2007, 10:07:04 am
With the release of VirtueMart 1.0.8, I'm attaching the updated pages shop.browse.php and shop_browse_queries.php (put in administrator\components\com_virtuemart\html).

Note that here there are also applied other hacks:

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: addison on January 02, 2007, 10:15:38 am
Really nice!

Can you change in Admin section and insert a check box for using this hack?

In Admin -> Configuration -> Site -> Available "Sort-by" fields I would like to add also Manufacturer/Brand

Thanks
Title: Re: Filter product category by manufacturer
Post by: Pisu on January 02, 2007, 11:30:24 am
I think this change is to be made in official release.. if developers wish. I already posted feature request in bugtracker: http://virtuemart.net/index.php?option=com_flyspray&Itemid=91&do=details&task_id=1070&option=com_flyspray&Itemid=91
Title: Re: Filter product category by manufacturer
Post by: zbir on January 16, 2007, 23:32:24 pm
Great job, very usefull modification:)

Do you know if there is a similar tool to filter manufacturers by category? The standard function in "mod_virtuemart_manufacturers" (Automatically select Manufacturers) doesn't seem to work - once I select a category it always says that "No manufacturers defined!"...

thanks
Title: Re: Filter product category by manufacturer
Post by: Pisu on January 17, 2007, 10:41:42 am
Do you know if there is a similar tool to filter manufacturers by category?

Do you mean categories of products, or categories of manufacturers?
My hack already filter manufacturer list if product category selected. If you mean category of manufacturers, I don't know, I never used that.
Title: Re: Filter product category by manufacturer
Post by: zbir on January 17, 2007, 16:15:12 pm
I ment "filter manufacturers by categories of products", so when client browses a cartain manufacturer he should be able to filter by selected category of products.

'mod_virtuemart_manufacturers' was a bad example, sorry, my mistake, forget about it.

Regards

Tom


Title: Re: Filter product category by manufacturer
Post by: Bill Smith on January 26, 2007, 12:13:42 pm
Remove these lines from shop.brose.php as it'll screw up your sef's

if (!empty($manufacturer_id) && $manufacturer_id<>0) {
         $url .= "&manufacturer_id=" . $manufacturer_id;
      }

Removing this block got it back working again.
Title: Re: Filter product category by manufacturer
Post by: Kay on February 02, 2007, 19:22:13 pm
Hi there..

Great mod thanks man!!
but for some reason when i changed it he automaticly posts it in my cart?
how is this possible could u guys please help

when i delete my add-to-cart template in browse_5.php
Title: Re: Filter product category by manufacturer
Post by: Pisu on February 03, 2007, 23:00:25 pm
Kay, I don't understand what you're meaning.. can I see your site?
Title: Re: Filter product category by manufacturer
Post by: Bill Smith on March 01, 2007, 07:44:33 am
This post is about as close as I can locate for what I need to achieve.

Instead of filtering manufacturers, I have products which can be New or Used.

I'd like a dropdown same as this which will state New, Used or Both.

I've spent 5 hours trying to come up with something however no luck at all. Any assistance?
Title: Re: Filter product category by manufacturer
Post by: WoSko on March 05, 2007, 17:29:09 pm
Hi Pisu!
That's great work! I have only one question. On the first place I have "Ustaw", where I need change this. I would like have "Producent".
Enywhere this is this what I looked for.
Many Thanks!
Title: Re: Filter product category by manufacturer
Post by: WoSko on March 06, 2007, 08:47:57 am
Hi Pisu.
I found it. And I changed this one as below:
added one line in vm lang, in my situation this was administrator/components/com_virtuemart/language/polish.php:
Code: [Select]
var $_PHPSHOP_MANUFACTURE = 'Producent';and I change in shop.browse.php this:
Code: [Select]
<option value=""><?php echo _CMN_SELECT ?></option>looks this now:
Code: [Select]
<option value=""><?php echo $VM_LANG->_PHPSHOP_MANUFACTURE ?></option>Thank a lot of again.
Title: Re: Filter product category by manufacturer
Post by: martin on March 12, 2007, 20:59:13 pm
Is it also possible to filter by price groups ?

It would like to add sort boxes that show all products between 100 and 200 euro.

Title: Re: Filter product category by manufacturer
Post by: Pisu on March 13, 2007, 16:31:07 pm
Instead of filtering manufacturers, I have products which can be New or Used.
I'd like a dropdown same as this which will state New, Used or Both.

Is it also possible to filter by price groups ?
It would like to add sort boxes that show all products between 100 and 200 euro.

Try opening another thread in forum. This is only for filter by manufacturer.
Title: Re: Filter product category by manufacturer
Post by: Bill Smith on March 20, 2007, 10:08:40 am
Ah, you mean those ones which never are answered.  Like the 10,000 + posts with no reply. Posted it here because obviously we presumed you would have been some assistance.
Title: Re: Filter product category by manufacturer
Post by: Pisu on March 20, 2007, 14:03:31 pm
I'm sorry, but remember that nobody is obliged to post replies and give assistance. This is a forum of a free and open source software, where anyone can take from other people's work. How much have you paid for VirtueMart? How much are paid people who post replies and give help in the forum? Because, although what you say, a lot of people find free help here; of course, not everybody. There's nothing to do about it.
Title: Re: Filter product category by manufacturer
Post by: Tiffany on March 21, 2007, 21:30:52 pm
I am sure this sounds really stupid, but I replaced the files and now I am not sure what to do to make the option to filter by manufacturer after selecting product category.  Could someone who has used this wonderful hack before possibly explain it to me?
Title: Re: Filter product category by manufacturer
Post by: Pisu on March 22, 2007, 14:21:58 pm
I am sure this sounds really stupid, but I replaced the files and now I am not sure what to do to make the option to filter by manufacturer after selecting product category.  Could someone who has used this wonderful hack before possibly explain it to me?

Hi spamcrap, the hack should work without other actions. Are you sure to have replaced the file shop.browse.php in folder \administrator\components\com_virtuemart\html ? You should see the selectbox for filtering by manufacturers, when browsing a product category, at right of the "order by" menu...

Can you tell me the address of your site, so I can take a look?
Title: Re: Filter product category by manufacturer
Post by: am_pix on March 22, 2007, 19:05:09 pm
The hack works on VirtueMart version 1.10 ?
Title: Re: Filter product category by manufacturer
Post by: Pisu on March 23, 2007, 10:52:12 am
The hack works on VirtueMart version 1.10 ?

Yes, I'm using VM 1.0.10 (not 1.10...) without problems. But for now I can't post updated files, because I've made many other custom changes at these files... You can try editing the code following the explanation at the first post... Let me know if you succeed!
Title: Re: Filter product category by manufacturer
Post by: Bill Smith on March 26, 2007, 19:14:13 pm
No worries steve irkle. If I wanted a grind on open source I would have asked you. If you can't do it forget it. Obviously incapable of it under those 10" goggles.
Title: Re: Filter product category by manufacturer
Post by: Anthony C. on April 04, 2007, 20:03:48 pm
VM 1.0.10 seems changing the way to present the query.

I couldn't get it to work following your first post.

For the first file is fine, but not the query file.

Please help!

Thank you,

Anthony
Title: Re: Filter product category by manufacturer
Post by: Anthony C. on April 04, 2007, 20:13:22 pm
I just realized that I don't need to edit the shop.browse_queries.php

just edit the shop.browse.php using your mod then it works.

Thanks,

Anthony
Title: Re: Filter product category by manufacturer
Post by: Pisu on April 05, 2007, 14:33:42 pm
very good! I have a good news: the feature is going to be implemented in next release of VM!

http://virtuemart.net/index.php?option=com_flyspray&Itemid=91&do=details&task_id=1070&option=com_flyspray&Itemid=91
Title: Re: Filter product category by manufacturer
Post by: vm_user on June 26, 2007, 18:05:35 pm
I have been using this hack feature for some time now and it work great, however I recently installed JoomSEF to make my URL's easier to read and now I get a broken link 404 page when I try to access the product flypage after the filter has been used (but only if it is used!)

It looks like it's trying to add the category filter onto the SEF URL - here's an example ... http://www.leconcepts.com/products/dvd-players/panasonic-dvd-s53-hdmi-dvd-player.html&manufacturer_id=1185

Any ideas why it's doing this and how to get around it??
Title: Re: Filter product category by manufacturer
Post by: Pisu on June 27, 2007, 13:33:22 pm
I never used JoomSEF... I don't know how it works.
The problem is that the manufacturer filter, add the manuf parameter to URL, and it is incompatibile with SEF URL... You should find a way to remove the "&manufacturer_id=1185" from URL..
Title: Re: Filter product category by manufacturer
Post by: vm_user on June 27, 2007, 21:35:42 pm
Well that was easier than I thought!
I simply removed the following line from the file shop.browse.php
Code: [Select]
$url .= "&manufacturer_id=" . $manufacturer_id;It was located around line 365 on my file, which has been extensively modified.
Title: Re: Filter product category by manufacturer
Post by: Pisu on June 29, 2007, 13:34:10 pm
Very good! I really don't remember why I added this line... it's useless.. maybe I was going mad with all that code!
Title: Re: Filter product category by manufacturer
Post by: Skye on July 31, 2007, 19:36:33 pm
This post is about as close as I can locate for what I need to achieve.

Instead of filtering manufacturers, I have products which can be New or Used.

I'd like a dropdown same as this which will state New, Used or Both.

I've spent 5 hours trying to come up with something however no luck at all. Any assistance?

I know this was relegated to another discussion, but felt that I should respond none the less.  I also was having an EXTREMELY hard time trying to find how to do this.

I have used the code that Pisu has above, and I made all of my manufacturers be the information I needed included.  In other words, create manufacturer Used, and New and assign them to each of your products.  You can then have it show up in the list.

In my case, I needed to allow the users to be able to choose a college, nfl, or mlb team once they had the browse results, with this code, it worked excellently.  Of course I don't have the ability to list manufacturers now, but we do have to trade off every now and then.  :)
Title: Re: Filter product category by manufacturer
Post by: Pisu on September 11, 2007, 10:00:49 am
If someone is interested, I updated the package, updating the files to VirtueMart version 1.0.12.

ZIP file in first post.
http://forum.virtuemart.net/index.php?topic=24349.msg64328#msg64328
Title: Re: Filter product category by manufacturer
Post by: Cat on September 11, 2007, 13:10:12 pm
Man, you rule! This thing that you created is really an option VM was missing.
Thanks a lot, buddy, fantastic job.

Regards,
Adam
Title: Re: Filter product category by manufacturer
Post by: Anthony C. on September 12, 2007, 00:14:29 am
Yeah that is right..

the mod is in this post.

^^ Glad you found it.

Anthony c.
Title: Re: Filter product category by manufacturer
Post by: eloo on October 29, 2007, 11:58:25 am
hello
i m trying to adapt your hack to filter product categories by product_type

I adapted your code like this :

i addes the variable $producttype_id
Code: [Select]
global $manufacturer_id,$producttype_id,$keyword1,$keyword2,$search_category,$DescOrderBy,$search_limiter,
$search_op,$orderby,$product_type_id, $default, $vmInputFilter, $VM_BROWSE_ORDERBY_FIELDS;
i added  ligne 120 *** NOW START THE PRODUCT LIST ***/
Code: [Select]
/
else {

/* Set Dynamic Page Title */
if( $category_id ) {
$db->query( "SELECT category_id, category_name FROM #__{vm}_category WHERE category_id='$category_id'");
$db->next_record();
$mainframe->setPageTitle( $db->f("category_name") );
}
elseif( $manufacturer_id) {
$db->query( "SELECT manufacturer_id, mf_name FROM #__{vm}_manufacturer WHERE manufacturer_id='$manufacturer_id'");
$db->next_record();
$mainframe->setPageTitle( $db->f("mf_name") );
}
elseif( $producttype_id) {
$db->query( "SELECT product_type_id, product_type_name FROM #__{vm}_product_type WHERE product_type_id='$producttype_id'");
$db->next_record();
$mainframe->setPageTitle( $db->f("product_type_name") );
}
and i added in section  <!-- ORDER BY .... FORM -->
just before  input hidden, i added :
Code: [Select]
$query  = "SELECT distinct a.product_type_id,a.product_type_name FROM #__{vm}_product_type AS a ";
if (!empty( $category_id ) ) {
    $query .= ", #__{vm}_product_category_xref AS d, "
    . " #__{vm}_product AS b, "
    . " #__{vm}_product_product_type_xref AS c "
    . " WHERE d.category_id='$category_id'"
    . " AND d.product_id = b.product_id AND b.product_publish='Y' "
    . " AND b.product_id = c.product_id AND c.product_type_id = a.product_type_id ";
}
$query .= "ORDER BY product_type_name ASC";
$db = new ps_DB;
$db->query( $query );

$res = $db->record;

?>
        <select class="inputbox" name="product_type_id" onchange="order.submit()">
            <option value=""><?php echo '-- ' _CMN_SELECT ' ' $VM_LANG->_PHPSHOP_MANUFACTURER_MOD ' --'?></option>
        <?php  
foreach ($res as $producttype) {
$selected '';
if( @$_REQUEST['product_type_id'] == $producttype->product_type_id ) {
$selected 'selected="selected"';      
}
echo "<option value=\"".$producttype->product_type_id ."\" $selected>"$producttype->product_type_name ."</option>\n";


        
?>

        </select>
this code works properly

in shop_browse_queries.php, i added just after /*** GET ALL PUBLISHED PRODUCTS FROM THAT MANUFACTURER ***/

Code: [Select]
/*** GET ALL PUBLISHED PRODUCTS FROM THAT producttype ***/
if (!empty($producttype_id)) {
$table_names .= ',`#__{vm}_product_product_type_xref`';
$where_clause[]  = "product_type_id='".$producttype_id."'";
$where_clause[] = "`#__{vm}_product`.`product_id`=`#__{vm}_product_product_type_xref`.`product_id` ";

}

i forgot something, the results page is empty !

Someone to help me, i'm a beginners ith joomla, virtuemart, and php ! ??

thank you very much
Title: Re: Filter product category by manufacturer
Post by: Pisu on October 29, 2007, 15:16:26 pm
I don't know... You should try to catch the final resulting query, and analyse the SQL code... You can do this simply adding, in shop_browse_queries.php, just before the script end, the echo command :

Code: [Select]
echo $q;
// BACK TO shop.browse.php !
?>
Title: Re: Filter product category by manufacturer
Post by: eloo on October 30, 2007, 12:59:15 pm
Thank you for the tip's !

the final resulting query :
Quote
LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` LEFT JOIN `#__{vm}_product_type_6` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type_6`.`product_id` LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id` WHERE `#__{vm}_product_category_xref`.`product_id`=`#__{vm}_product`.`product_id` AND `#__{vm}_product_category_xref`.`category_id`=`#__{vm}_category`.`category_id` AND `#__{vm}_product_category_xref`.`category_id`=39 AND `#__{vm}_product_product_type_xref`.`product_type_id`=6 AND ((`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` AND `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id`) OR `#__{vm}_product_price`.`product_id` IS NULL) AND `#__{vm}_shopper_group`.`default` = 1 AND `product_parent_id`=0 AND `product_publish`='Y' GROUP BY `#__{vm}_product`.`product_sku` ORDER BY `#__{vm}_product`.`product_name` ASC

i dont know  how i can modify  ???
Quote
LEFT JOIN `#__{vm}_product_type_6` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type_6`.`product_id` LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id
that seems wrong

i need some help !  :)

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: Pisu on October 30, 2007, 14:20:50 pm
Ok so the problem seems to be here...
Quote
#__{vm}_product_type_6
The number id "6" is appended to the table name... That is wrong...
Title: Re: Filter product category by manufacturer
Post by: eloo on October 30, 2007, 16:19:19 pm
yes you're right.
i modify in original shop_browse_queries.php, the lines :
Code: [Select]
// Filter Products by Product Type
if (!empty($product_type_id)) {
require_once (CLASSPATH."ps_product_type.php");
$ps_product_type = new ps_product_type();

// list parameters:
$q  = "SELECT `parameter_name`, `parameter_type` FROM `#__{vm}_product_type_parameter` WHERE `product_type_id`='$product_type_id'";
$db_browse->query($q);

/*** GET ALL PUBLISHED PRODUCT WHICH MATCH PARAMETERS ***/
$join_array[] = "LEFT JOIN `#__{vm}_product_type_$product_type_id` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type_$product_type_id`.`product_id` ";
$join_array[] = "LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id` ";
$where_clause[] = "`#__{vm}_product_product_type_xref`.`product_type_id`=$product_type_id ";

with this lines
Code: [Select]
// Filter Products by Product Type
if (!empty($product_type_id)) {
require_once (CLASSPATH."ps_product_type.php");
$ps_product_type = new ps_product_type();

// list parameters:
$q  = "SELECT `parameter_name`, `parameter_type` FROM `#__{vm}_product_type_parameter` WHERE `product_type_id`='$product_type_id'";
$db_browse->query($q);

/*** GET ALL PUBLISHED PRODUCT WHICH MATCH PARAMETERS ***/
$join_array[] = "LEFT JOIN `#__{vm}_product_type` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type`.`product_id` ";
$join_array[] = "LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id` ";
$where_clause[] = "`#__{vm}_product_product_type_xref`.`product_type_id`=$product_type_id ";

now the final resluting quey is :
Quote
LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` LEFT JOIN `#__{vm}_product_type` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type`.`product_id` LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id` WHERE `#__{vm}_product_category_xref`.`product_id`=`#__{vm}_product`.`product_id` AND `#__{vm}_product_category_xref`.`category_id`=`#__{vm}_category`.`category_id` AND `#__{vm}_product_category_xref`.`category_id`=39 AND `#__{vm}_product_product_type_xref`.`product_type_id`=19 AND ((`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` AND `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id`) OR `#__{vm}_product_price`.`product_id` IS NULL) AND `#__{vm}_shopper_group`.`default` = 1 AND `product_parent_id`=0 AND `product_publish`='Y' GROUP BY `#__{vm}_product`.`product_sku` ORDER BY `#__{vm}_product`.`product_name` ASC


and no products were found  :-[
Title: Re: Filter product category by manufacturer
Post by: Bob Hall on December 17, 2007, 17:50:07 pm
For VM 1.0.13a, can we just use the 1.0.12 files? This sounds like exactly what I need for our new VM shop.
Title: Re: Filter product category by manufacturer
Post by: Pisu on December 17, 2007, 20:40:00 pm
Attaching the package updated for VM 1.0.13; in this version, only the file shop.browse.php need to be changed!

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: hussan on December 20, 2007, 12:58:29 pm
Hello

its a great job, bot how i show the manufacturer name with de name of product:

example: TOSHIBA A215-S4697 in my site only show the name(A215-S4697)

can helpme?

h
Title: Re: Filter product category by manufacturer
Post by: Pisu on December 20, 2007, 13:56:55 pm
its a great job, bot how i show the manufacturer name with de name of product:
example: TOSHIBA A215-S4697 in my site only show the name(A215-S4697)

In file shop.browse.php, just after this line:
Code: [Select]
$product_cell = str_replace( "{product_sku}", $db_browse->f("product_sku"), $product_cell );
Add this:
Code: [Select]
$product_cell = str_replace( "{manufacturer}", $ps_product->get_mf_name($db_browse->f("product_id")), $product_cell );

Now, you can use the {manufacturer} in templates/browse_1.php, in the position where do you want to see the manufacturer name.
Title: Re: Filter product category by manufacturer
Post by: hussan on December 20, 2007, 14:00:52 pm
tanks a lot!

h2
Title: Re: Filter product category by manufacturer
Post by: hussan on December 21, 2007, 13:30:20 pm
Pisu,

how i order my browse page in this order:

manufacturer and product_name

now in my page: www.lojasnoparaguai.net/notebook.html order by name products... i need order by manufacturer, product_name

thanks for your replies

h2
Title: Re: Filter product category by manufacturer
Post by: studio16 on March 18, 2008, 21:21:58 pm
Hey this is really a great feature, the only thing is how to get it to work with a result browse page after product search. When you search then you get all the manufacturers.

Is there any solutions for this problem?

thanks in advance
Title: Re: Filter product category by manufacturer
Post by: dimpapadop on March 24, 2008, 13:27:42 pm
Attaching the package updated for VM 1.0.13; in this version, only the file shop.browse.php need to be changed!

hi there guys! great great work!!!

Can you do a version for joomla 1.0.15 too?

please do
Title: Re: Filter product category by manufacturer
Post by: dimpapadop on March 24, 2008, 21:58:22 pm
Hey guys, tried the 1.013a version hack here and works in joomla 1.0.15 too.
Thank you very much!!!
Title: Re: Filter product category by manufacturer
Post by: Pisu on March 30, 2008, 20:08:38 pm
Here you can find the latest package (ok for VM 1.0.14 / 1.0.15):
http://www.vmitalia.net/index.php?option=com_docman&task=doc_download&gid=54&Itemid=58
Title: Re: Filter product category by manufacturer
Post by: studio16 on April 03, 2008, 16:20:01 pm
Here you can find the latest package (ok for VM 1.0.14 / 1.0.15):
http://www.vmitalia.net/index.php?option=com_docman&task=doc_download&gid=54&Itemid=58

is it possible to chain the manufacturer to a product instead of a category so after a search you can filter the results by manufacturer as well?
Title: Re: Filter product category by manufacturer
Post by: Alex on April 16, 2008, 21:15:57 pm
Thank you for this hack!! :)
How similar filter could be done, but the filter that would contain categories - so as in the list of products of the certain manufacturer the category of definite product of that manufacturer could be also filtered?
Title: Re: Filter product category by manufacturer
Post by: celine1988 on May 15, 2008, 10:54:31 am
i get the following error:

Notice: Undefined variable: product_cell in /var/www/vhost/direxiondm.nl/home/html/joomla2/administrator/components/com_virtuemart/html/shop.browse.php on line 498

can i use this code anyway in virtuemart 1.1?
Title: Re: Filter product category by manufacturer
Post by: studio16 on May 21, 2008, 15:50:47 pm
Hey this is really a great feature, the only thing is how to get it to work with a result browse page after product search. When you search then you get all the manufacturers.
Is there any solutions for this problem?
thanks in advance
is it possible to chain the product_id to the mf_name/manufacturer_id instead of the category_id so that it works on a search result page?
something like:
$query  = "SELECT distinct a.manufacturer_id,a.mf_name FROM #__{vm}_manufacturer AS a ";
if (!empty( $product_id ) ) {
    $query .= ", #__{vm}_product_mf_xref AS c, "
    . " #__{vm}_product AS b, "
    . " WHERE c.product_id='$product_id'"
    . " AND c.product_id = b.product_id AND b.product_publish='Y' "
    . " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";
}
$query .= "ORDER BY mf_name ASC";
$db = new ps_DB;
$db->query( $query );
$res = $db->record;
?>
        <select class="inputbox" name="manufacturer_id" onchange="order.submit()">
            <option value=""><?php echo '-- ' . _CMN_SELECT . ' ' . $VM_LANG->_PHPSHOP_MANUFACTURER_MOD . ' --'?></option>
        <?php 
foreach ($res as $manufacturer) {
$selected = '';
if( @$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id ) {
$selected = 'selected="selected"';     
}
echo "<option value=\"".$manufacturer->manufacturer_id ."\" $selected>". $manufacturer->mf_name ."</option>\n";
}
        ?>
        </select>


but now i get all the manufacturers
Title: Re: Filter product category by manufacturer
Post by: studio16 on May 30, 2008, 16:44:23 pm
<?php
$db = new ps_DB;
      $db->query( ($list) );
   
      $res = $db->record;
      
            
      ?>
        <select  class="inputbox" name="category_id" onchange="order.submit()">
            <option value=""><?php echo $VM_LANG->_CATEGORY_FILTER ?></option>
        <?php 
         foreach ($res as $category) {
            
               $selected = '';
               if( @$_REQUEST['category_id'] == $category->category_id ) {
                     $selected = 'selected="selected"';     
               }
               echo "<option value=\"".$category->category_id ."\" $selected>". $category->category_name."</option>\n";
         }
?>
 </select>
this code gives me the category (names) on the particular search result browse page and ii filters correctly.
and i added the category fields in the browse.queries.php

only thing is how to remove duplicates. any suggestions?
Title: Re: Filter product category by manufacturer
Post by: provid on June 09, 2008, 12:35:29 pm
Hi everyone. Will this mod work with 1.1.0? or is ther an other hack for 1.1.0?

many thanks
Title: Re: Filter product category by manufacturer
Post by: Carlv1428 on August 01, 2008, 15:45:24 pm
Hi Everyone,

I was looking for those kind of feature for a long time, ...

I have just one question, since I updated my Virtuemart with the new code i don't see the sub categories anymore....

If you take a look at http://www.locastore.be (http://www.locastore.be)
If you have a look at a categorie like computer components your dont have the display of the subcategories (shown on the menu but not in the middle page...
Now it says Array and nothing more.

Help please...
Title: Re: Filter product category by manufacturer
Post by: Niki Filippini on August 01, 2008, 18:25:38 pm
Hi here there's a hack for the VM 1.12

It needs some test

Hi all
Niki

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: CranialBlaze on August 05, 2008, 15:10:59 pm
Hey

I just tested the 1.12 version of the modification on my local site and it works perfectly, i just modified the 'browse_filterbymf.tpl.php' file so that on the browse page it shows Manufacturer as the initial value.

Thank you guys this will help my store out a lot
Title: Re: Filter product category by manufacturer
Post by: Viames on August 07, 2008, 00:41:10 am
there's a hack for the VM 1.12
It needs some test

Hi and thanks for the hack!
I'm testing this piece of code on J1.5 with VM 1.12 svn and I've got this notices on category view:

Code: [Select]
Notice: Undefined variable: VM_BROWSE_FILTERBY_MF in /components/com_virtuemart/themes/default/templates/browse/includes/browse_filterbymf.tpl.php on line 7
:   
Notice: Undefined variable: product_type_id in /components/com_virtuemart/themes/default/templates/browse/includes/browse_orderbyform.tpl.php on line 45

P.S. I would be nice to have this useful feature available on standard VirtueMart!

Title: Re: Filter product category by manufacturer
Post by: Sulpher on August 30, 2008, 13:39:35 pm
Pisu, thanks a lot for great solution!
Title: Re: Filter product category by manufacturer
Post by: kayut on October 08, 2008, 13:21:44 pm
Hi,
I use Joomla 1.5.7.

I downloaded the files from this post:
Quote
Hi here there's a hack for the VM 1.12
It needs some test
And overwrite the old files with this.
But I cannot see any changes.

Where can I find the "Order by Manufacturer"??
Thanks
Title: Re: Filter product category by manufacturer
Post by: kayut on October 08, 2008, 23:05:48 pm
Do I have to change some files??

Please help me!   ???
Title: Re: Filter product category by manufacturer
Post by: kayut on October 10, 2008, 11:32:54 am
Hi,

Does work this hack for Joomla 1.5?
Title: Re: Filter product category by manufacturer
Post by: korb on November 09, 2008, 18:08:49 pm
It seem to work, but can it be done a similar code for product types parameters?
Title: Re: Filter product category by manufacturer
Post by: woonski on November 12, 2008, 13:57:54 pm
hi,

i use joomla 1.5.7, and i have problem

Code: [Select]
Warning: vmTemplate::include(/home/arekkat/public_html/katalog/components/com_virtuemart/themes/default/templates/browse/includes/browse_filterbymf.tpl.php) [function.vmTemplate-include]: failed to open stream: Permission denied in /home/arekkat/public_html/katalog/administrator/components/com_virtuemart/classes/template.class.php on line 213

Warning: vmTemplate::include() [function.include]: Failed opening '/home/arekkat/public_html/katalog/components/com_virtuemart/themes/default/templates/browse/includes/browse_filterbymf.tpl.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/arekkat/public_html/katalog/administrator/components/com_virtuemart/classes/template.class.php on line 213

:(
Title: Re: Filter product category by manufacturer
Post by: geonet on November 12, 2008, 14:30:46 pm
Hello I use FilterManufactorer_VM_1v12 and it works perfect.

But if it is possible i want something more... I want to see the categories page browsed by manufacturers.

example see the categories only for each manufacturer seperately.

has anyone any ideas?

Thank you
Title: Re: Filter product category by manufacturer
Post by: chiareu on December 05, 2008, 23:59:34 pm
Joomla 1.5.8, VM 1.1.2 working with one observation.
In the advanced search browse page, the dropdown list contain all manufacturers.

I sustain korb's question: can it be done a similar code for product types parameters?
Title: Re: Filter product category by manufacturer
Post by: Siteholder on January 15, 2009, 22:15:36 pm
Hi here there's a hack for the VM 1.12
It needs some test
Hi all
Niki

Hi Nikki, that's a great and usefull hack. Special thanks from Moscow.
But there is a little bug.

When you choose a manufactor and after filtering remains more then 1 product - it's OK! You can proceed with filtering, and sorting.
BUT! If the result of filtering is 1 product. The Filtering box and the sorting box disapear.
And you have 1 product on the blank page with no option to return to all products or to choose another manufactor. The only way is to reload the category page by selecting it from the category list.

If you are gonna fix this. It would be great to have an upgraded version here. Thanks!
Title: Re: Filter product category by manufacturer
Post by: pcinfo on January 27, 2009, 17:24:21 pm
Hi here there's a hack for the VM 1.12
It needs some test
Hi all
Niki
Thx for your solution. It works great, buuuuttt :) i have a question. I'd like after I select an manufacture, to have the possibility to change it or to renounce to the filter. How can I do this?

My site is
Title: Re: Filter product category by manufacturer
Post by: sodego on February 22, 2009, 01:52:20 am
Unfortunately when I added this hack I cannot use manufacturer name
<?php echo $mf_name; ?> on browse pages. It simply shows nothing.

I want to show my customers manufacturers name on browse pages.
Title: Re: Filter product category by manufacturer
Post by: DRACULINOS on May 17, 2009, 18:03:27 pm
I m uploading the filter for the 1.1.3 version of Virtuemart.

Always take backup of the overwritten files!!

You should not add any string in the language files with this version of the filter.

I will try to include this filter in the next releases of Vm.

Thanks to Pisu and all the guys helps for it!

Best Regards
Theo

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: mr.ado on June 08, 2009, 23:16:23 pm
Is it possible to make filter by price?
Title: Re: Filter product category by manufacturer
Post by: Intramedial on June 13, 2009, 04:55:00 am
I m uploading the filter for the 1.1.3 version of Virtuemart.

Always take backup of the overwritten files!!

You should not add any string in the language files with this version of the filter.

I will try to include this filter in the next releases of Vm.

Thanks to Pisu and all the guys helps for it!

Best Regards
Theo

Do you have a solution how to make it work in combination with the hack to show all products of the subcats recursively also in each parent cat. Currently when adding this hack to the modified codes, it works perfectly from like the 2nd cat level on but also there only sometimes, in some cats, but not in the main top cats and a lot of others. There no manufacturers are shown at all, but in some subcat they are. This should stand in a relation that there is this code added or replaced in the browse.queries, the code is from here in the forums.

http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0

Code: [Select]
// Filter Products by Category
/*
* Returns an array of the categories ids recursively for a given category
* untreeCat copy lashae (virtuemart forum http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0)
* rewritten by Creb (to use shop.browse page detection)
*/
if( $category_id ) {
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
//MODIFIED FOR FILTER MANUFACTORER

//} elseif( empty( $keyword ) && empty( $manufacturer_id )) {

} elseif( empty( $keyword )) {

//END MODIFIED FOR FILTER MANUFACTORER

if ($_GET["page"]=="shop.browse") {
  //$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
$kategoriListesi = array();
$ps_product_category->untreeCat($category_id, $kategoriListesi);
$qkat = " `#__{vm}_product_category_xref`.`category_id` IN(".$category_id . ",";
foreach ($kategoriListesi as $kat)
{
$qkat .= $kat . ',';
}
$qkat .= ")";

$qkat = str_replace(',)', ')', $qkat);
$where_clause[] = $qkat;
} else {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}

}
}

Title: Re: Filter product category by manufacturer
Post by: Andrew Hemming on July 26, 2009, 20:56:13 pm
Works great - thanks!
Title: Re: Filter product category by manufacturer
Post by: Vlada_bgd on September 13, 2009, 13:17:12 pm
I don‚t C html folder in public_html/component/com_virtuemart....??
Title: Re: Filter product category by manufacturer
Post by: Fetka on October 16, 2009, 11:34:59 am
Thank U! Very Mach!!!!! :)
Title: Re: Filter product category by manufacturer
Post by: kodyxgen on November 11, 2009, 17:01:13 pm
Hi i nead Filter product category by manufacturer in VM 1.1.4
pleas
Title: Re: Filter product category by manufacturer
Post by: DRACULINOS on November 18, 2009, 01:04:17 am
I m uploading the filter for the 1.1.4 version of Virtuemart.

Always take backup of the overwritten files!!

Best Regards
Theo

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: korb on November 18, 2009, 23:14:23 pm
Nice update :)
Title: Re: Filter product category by manufacturer
Post by: simovina on November 20, 2009, 17:29:23 pm
Thank you very much Theo !
Title: Re: Filter product category by manufacturer
Post by: coolerUA on December 04, 2009, 10:54:52 am
Hi!
Anyone knows how to Filter manufacturer by product category?
Title: Re: Filter product category by manufacturer
Post by: AlexThunder on December 13, 2009, 13:02:56 pm
Thanks for 1.1.4 update.

Select menu is good, but...
Is it possible to have this filter as a link list?

I tried to remove selections and chanhe option echo for <a ...>, but seems there is all about "order.submit()".... Therefore I'm a bit lost. :)
Title: Re: Filter product category by manufacturer
Post by: thanoss43 on January 13, 2010, 11:12:10 am
Hello,

I have just installed it for VM 1.1.4 and it works great.
THANK YOU!

I have now two questions, that are not important though.

1. Can I make it work with Joomfish (to change "Select Manufacturer" to another language when a user changes language)

2. This is also asked above: When a user browses by manufacturer, I would like the filter to work as "Select Category". How can we do this?

Anyway, my site works perfectly with your hack, I have about 10.000 products and this saves the user lots of time!
Title: Re: Filter product category by manufacturer
Post by: Catalin on February 02, 2010, 17:55:05 pm
Very nice job. This should be default in VM.
Now, i have a question. How can i display the results in 3 or 4 products on a row, instead of one on a row ?
Title: Re: Filter product category by manufacturer
Post by: atzounis on March 12, 2010, 11:10:43 am
Hello,
Is there a way to implement a similar functionality like:
Eshop > Product Categories > Category1 > Manufacturers(that have products in this category) > Manufacturer "X" Category Products

I mean instead of having a drop-down filtering show a screen with manufaturers logos.

Thanks a lot!
 :)

Antonis
Title: Re: Filter product category by manufacturer
Post by: vm_user on March 21, 2010, 01:13:02 am
Thank you for uploading the revised version for 1.1.4!

Install was very straightforward too!
Title: Re: Filter product category by manufacturer
Post by: djreason on April 01, 2010, 19:01:53 pm
When you filter by manufacturer, the result has no navigation back to the original browse page.  Also, there is no ability to continue to filter the filtered by manufacture page to sort by price or sku.  Can these mods be made?  I dont know how to do them or I would contribute them myself.

Please help!

p.s...awesome addition to VM.  Very helpful.
Title: Re: Filter product category by manufacturer
Post by: tekilas on April 05, 2010, 17:31:52 pm
First of all, excuse my English .... (Not master the language too)

The filter is spectacular ..... but wondered if instead of a dropdown list could be done with "icons" and the manufacturer's logo (not if I explain it)

Thanks

Rodrigo
Title: Re: Filter product category by manufacturer
Post by: ovg on April 19, 2010, 16:23:49 pm
Dear,

Thanks for this filter. It works great for me. I've one question. Where can I change the text: "Select Manufacturer:" ?

I cannot find it in the language file and also not in the files of the .zip. So can anyone help me with this?

Regards,
OVG
Title: Re: Filter product category by manufacturer
Post by: vm_user on April 19, 2010, 22:19:48 pm
It's on line 11 of  \components\com_virtuemart\themes\default\templates\browse\includes  browse_filterbymf.tpl.php
Title: Re: Filter product category by manufacturer
Post by: ovg on April 20, 2010, 11:36:45 am
Thanks vm_user. I've change the text. Great job.

Kind regards,
ovg
Title: Re: Filter product category by manufacturer
Post by: Belkira on July 15, 2010, 09:48:52 am
First of all, excuse my English.

Thanks for this filter.

I allowed myself to update this hack for filter by manufacturer and category product ( Caution ! this hack isn't optimized ).

Update :

browse_filterbymf.tpl.php
Code: [Select]
<?php
if (!defined('_VALID_MOS') && !defined('_JEXEC'))
    die(
'Direct Access to ' basename(__FILE__) . ' is not allowed.');
mm_showMyFileName(__FILE__);
?>



<?php
if (sizeof($VM_BROWSE_FILTERBY_MF) < 2) {
    
// return;
}
?>

<p id="manufacturerSorting">
<?php echo "Choix de la marque " ?> :
<select class="inputbox" name="manufacturer_id" onchange="order.submit()">
    <option value="product_list" ><?php echo $VM_LANG->_('PHPSHOP_SELECT'?></option>
    <?php
    $query 
"SELECT distinct a.manufacturer_id,a.mf_name FROM #__{vm}_manufacturer AS a ";
    if (!empty(
$category_id)) {
        
$query .= ", #__{vm}_product_category_xref AS d, "
                
" #__{vm}_product AS b, "
                
" #__{vm}_product_mf_xref AS c "
                
" WHERE d.category_id='$category_id'"
                
" AND d.product_id = b.product_id "
                
" AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";
    }
    
$query .= "ORDER BY mf_name ASC";
    
$db = new ps_DB;
    
$db->query($query);

    
$res $db->record;

    foreach (
$res as $manufacturer) {
        
$selected '';
        if (@
$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id) {
            
$selected 'selected="selected"';
        }
        echo 
"<option value=\"" $manufacturer->manufacturer_id "\" $selected>" $manufacturer->mf_name "</option>\n";
    }
    
?>

</select>
</p>
<p id="categorySorting">
<?php echo "Choix de la catégorie " ?> :
<?php
// list of category
    
$query "SELECT a.category_id,a.category_name,b.category_parent_id FROM #__{vm}_category AS a, #__{vm}_category_xref AS b WHERE a.category_publish = 'Y' ";
    
$query .= " AND (a.category_id = b.category_child_id) ";
    
$query .= "ORDER BY a.category_name ASC";
    
$db = new ps_DB;
    
$db->query($query);
    
$res $db->record;
?>

    <select class="inputbox" name="category_id" onchange="order.submit()">
        <option value=""><?php echo $VM_LANG->_('PHPSHOP_SELECT'?></option>
    <?php
    
if (!function_exists(recursive_get_parent_name)) {
        function 
recursive_get_parent_name($res$idParent) {
            if (
$idParent !== 0) {
                foreach (
$res as $directChild) {
                    if (
$idParent == $directChild->category_id) {
                        
array_push($_SESSION['categorySorting'], $directChild->category_name);
                        
recursive_get_parent_name($res$directChild->category_parent_id);
                    }
                }
            }
        }
    }
    foreach (
$res as $cat) {
        
$selected '';
        
// init 
        
$_SESSION['categorySorting'] = array();
        if (@
$_REQUEST['category_id'] == $cat->category_id) {
            
$selected 'selected="selected"';
        }
        echo 
"<option value=\"" $cat->category_id "\" $selected>";
        
recursive_get_parent_name($res$cat->category_parent_id);
        
krsort($_SESSION['categorySorting']);
        echo 
implode(" >> "$_SESSION['categorySorting']);
        if (!empty(
$_SESSION['categorySorting']))
            echo 
' >> ';
        echo 
$cat->category_name "</option>\n";
    }
    
?>

</select>
</p>

browse_orderbyform.tpl.php :
Code: [Select]
<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
mm_showMyFileName(__FILE__); ?>


<!-- ORDER BY .... FORM -->
<form action="<?php echo $mm_action_url."index.php" ?>" method="get" name="order">

<?php
if( !empty( $VM_BROWSE_ORDERBY_FIELDS )) {
echo $this->fetch'browse/includes/browse_orderbyfields.tpl.php');

// This is the toggle button for Descending / Ascending Order
// It is wrapped into a JS function with a noscript area to keep it accessible
echo mm_writeWithJS('&nbsp;<input type="hidden" name="DescOrderBy" value="'.$asc_desc[0].'" /><a href="javascript: document.order.DescOrderBy.value=\''.$asc_desc[1].'\'; document.order.submit()"><img src="'$mosConfig_live_site."/images/M_images/$icon"  .'" border="0" alt="'$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_'.$asc_desc[0].'ENDING_ORDER') .'" title="'.$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_'.$asc_desc[0].'ENDING_ORDER') .'" width="12" height="12" /></a>',
      
'<select class="inputbox" name="DescOrderBy">
            <option '
.$selected[0].' value="DESC">'.$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_DESCENDING_ORDER').'</option>
            <option '
.$selected[1].' value="ASC">'.$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_ASCENDING_ORDER').'</option>
        </select>
        <input class="button" type="submit" value="'
.$VM_LANG->_('PHPSHOP_SUBMIT').'" />');
}
    
//CHANGES FOR FILTER MANUFACTORER
    
echo $this->fetch'browse/includes/browse_filterbymf.tpl.php');
    
//END CHANGES FOR FILTER MANUFACTORER
?>

    <input type="hidden" name="Itemid" value="<?php echo $Itemid ?>" />
    <input type="hidden" name="option" value="com_virtuemart" />
    <input type="hidden" name="page" value="shop.browse" />
        <!--  CHANGES FOR FILTER CATEGORY
    <input type="hidden" name="category_id" value="<?php echo $category_id ?>" />
        -->
    <!--  CHANGES FOR FILTER MANUFACTORER
    <input type="hidden" name="manufacturer_id" value="<?php echo $manufacturer_id ?>" />
        -->
    <input type="hidden" name="keyword" value="<?php echo $keyword ?>" />
    <input type="hidden" name="keyword1" value="<?php echo $keyword1 ?>" />
    <input type="hidden" name="keyword2" value="<?php echo $keyword2 ?>" />
<?php
if( !empty( $product_type_id )) {
echo '<input type="hidden" name="product_type_id" value="'.$product_type_id.'" />'
echo $ps_product_type->get_parameter_form($product_type_id);
}
if( 
$show_top_navigation ) {
?>

&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $VM_LANG->_('PN_DISPLAY_NR'?>&nbsp;&nbsp;

<?php $pagenav->writeLimitBox(); ?>
<noscript><input type="submit" value="<?php echo $VM_LANG->_('PHPSHOP_SUBMIT'?>" /></noscript>

    <!-- PAGE NAVIGATION AT THE TOP -->
    <br/>
    <div style="text-align:center;"><?php 
    
$pagenav->writePagesLinks$search_string );
    
echo '<br />';
    
$pagenav->writePagesCounter();
      
?>

    </div>
   
<?php

}
?>

</form>

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: Web Marketing Vicenza on August 23, 2010, 16:59:37 pm
Anybody has this hack for 1.1.5?
Thanks a lot.
Title: Re: Filter product category by manufacturer
Post by: cz_dry on August 30, 2010, 10:58:09 am
Works great, but after applying filter, the product list style is changed to Product list (no table, div-based). Can anyone help me to show the filtered products with the default table style?
And did anyone find something similar to filter according to any custom attributes?
____
Modified:
I found how to preserve tabbed style, I just added "width: 240px;" parameter to browseProductContainer style in the theme.css file in components/com_virtuemart/themes/default directory.
Title: Re: Filter product category by manufacturer
Post by: DRACULINOS on September 25, 2010, 18:23:27 pm
I m uploading the filter (only) for the 1.1.5 version of Virtuemart.

Always take backup of the overwritten files!!


Best Regards
Theo

[attachment cleanup by admin]
Title: Re: Filter product category by manufacturer
Post by: thanoss43 on October 19, 2010, 23:19:37 pm
Hi guys!

I have upgraded to 1.1.5 a month ago, and just realised that this filter doesn't work now. It shows all the products of the selected manufacturer.

The link above doesn't work.

Can somebody upload it again?

Thanks a lot.

EDIT: It works now. Thanks!
Title: Re: Filter product category by manufacturer
Post by: Giannis86 on October 30, 2010, 12:26:58 pm
Hello,


A few hours ago i paid for a component for doing the exact same thing. I didnt quite work that good though so i am very glad that i found this mod!

I have one question though. Is it possible to have the filter remain in place after you have selected one manufacturer? I want to do this so that a customer wont have to redo the whole thing in order to select another manufacturer.

Regards,
Giannis
Title: Re: Filter product category by manufacturer
Post by: Qzmarcia on December 17, 2010, 06:28:55 am
HI, Did you have the version to vm 1.1.6 ?

Or i can use 1.1.5 for my vm 1.1.6 ?

To regards
Title: Re: Filter product category by manufacturer
Post by: ueciccio on December 23, 2010, 14:50:34 pm
HI, Did you have the version to vm 1.1.6 ?

Or i can use 1.1.5 for my vm 1.1.6 ?

To regards

I have tested the filter named "FilterManufacturer_VM_1.1.5.zip"
on a vm 1.1.6 and it works fine.
Title: Re: Filter product category by manufacturer
Post by: diablo on January 18, 2011, 20:25:11 pm
Search line no display

Code: [Select]
$search_string = '';
if ( $num_rows > 1 && @$_REQUEST['output'] != "pdf") {
if ( $num_rows > 5 ) { // simplified logic
$search_string = $mm_action_url."index.php?option=com_virtuemart&amp;category_id=$category_id&amp;page=$modulename.browse";
$search_string .= empty($manufacturer_id) ? '' : "&amp;manufacturer_id=$manufacturer_id";
$search_string .= empty($keyword) ? '' : '&amp;keyword='.urlencode( $keyword );
if (!empty($keyword1)) {
$search_string.="&amp;keyword1=".urlencode($keyword1);
$search_string.="&amp;search_category=".urlencode($search_category);
$search_string.="&amp;search_limiter=$search_limiter";
if (!empty($keyword2)) {
$search_string.="&amp;keyword2=".urlencode($keyword2);
$search_string.="&amp;search_op=".urlencode($search_op);
}
}

if (!empty($product_type_id)){
foreach($_REQUEST as $key => $value){
if (substr($key, 0,13) == "product_type_"){
$val = vmGet($_REQUEST, $key );
if( is_array( $val )) {
foreach( $val as $var ) {
$search_string .="&".$key."[]=".urlencode($var);
}
} else {
$search_string .="&".$key."=".urlencode($val);
}
}
}
}

}
$search_string=$sess->url($search_string);

$tpl->set( 'VM_BROWSE_ORDERBY_FIELDS', $VM_BROWSE_ORDERBY_FIELDS);
    if ($DescOrderBy == "DESC") {
        $icon = "sort_desc.png";
        $selected = Array( "selected=\"selected\"", "" );
  $asc_desc = Array( "DESC", "ASC" );
}
else {
  $icon = "sort_asc.png";
        $selected = Array( "", "selected=\"selected\"" );
        $asc_desc = Array( "ASC", "DESC" );
    }
$tpl->set( 'orderby', $orderby );
$tpl->set( 'icon', $icon );
$tpl->set( 'selected', $selected );
$tpl->set( 'asc_desc', $asc_desc );
$tpl->set( 'category_id', $category_id );
$tpl->set( 'manufacturer_id', $manufacturer_id );
$tpl->set( 'keyword', urlencode( $keyword ) );
$tpl->set( 'keyword1', urlencode( $keyword1 ) );
$tpl->set( 'keyword2', urlencode( $keyword2 ) );
$tpl->set( 'Itemid', $Itemid );

if( $show_top_navigation ) {
$tpl->set( 'search_string', $search_string );
}

$orderby_form = $tpl->fetch( 'browse/includes/browse_orderbyform.tpl.php' );
$tpl->set( 'orderby_form', $orderby_form );
//CHANGES FOR MANUFACTORER FILTER
$orderby_form = $tpl->fetch( 'browse/includes/browse_filterbymf.tpl.php' );
$tpl->set( 'filterby_mf', $orderby_form );
//END CHANGES FOR MANUFACTORER FILTER
    }
    else {

    $tpl->set( 'orderby_form', '' );
//CHANGES FOR MANUFACTORER FILTER
$tpl->set( 'filterby_mf', '' );
//END CHANGES FOR MANUFACTORER FILTER
    }


Search line can disapper if number of products of selected manufacturer is less < 2.

On line 181 shop.browse.php
if ( $num_rows > 1 && @$_REQUEST['output'] != "pdf")

you can replace it with

if ( $num_rows > 0 && @$_REQUEST['output'] != "pdf")

Title: Re: Filter product category by manufacturer
Post by: Mike_Griffiths on January 21, 2011, 13:05:07 pm
I don't know if there is a quick answer to this question or whether i have to trace my footsteps back.

The wording "Select Manufacturer" has disappeared from next to the drop down manufacturer box on my site. I have lately installed the VM Meta data/keyword hack and have enabled search engine friendly urls. I tried adding the following code into my shop.browse file but returned an error on my site:

//CHANGES FOR MANUFACTORER FILTER
      $orderby_form = $tpl->fetch( 'browse/includes/browse_filterbymf.tpl.php' );
      $tpl->set( 'filterby_mf', $orderby_form );      
      //END CHANGES FOR MANUFACTORER FILTER
    }
    else {
       $tpl->set( 'orderby_form', '' );
   //CHANGES FOR MANUFACTORER FILTER
   $tpl->set( 'filterby_mf', '' );
   //END CHANGES FOR MANUFACTORER FILTER
    }

I am using VM 1.1.4. The dropdown box functionality seems to work fine and inside i still have the manufacturers listed, but the "Select Manufacturer" wording has well and truly disappeared.

My site is www dot sigma-sports dot co dot uk.

Please can anyone help me sort this out or suggest where i should atleast start. Thank you in advance.
Title: Re: Filter product category by manufacturer
Post by: Aibolit66 on February 11, 2011, 14:11:00 pm
Hey great job. Thanks.

How about Filter product manufacturer by category.
Did anybody thought about it?
I mean  categories filter on a manufacturers page?
Anybody?
Title: Re: Filter product category by manufacturer
Post by: chrispang on February 21, 2011, 11:02:18 am
Dear All

I want setting this filter in my VM+JoomFish Search+this filfer
anyone can teach me how to add script to shop_browse_queries.php

Code: [Select]
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/*
* This file is to be included from the file shop.browse.php
* and uses variables from the environment of the file shop.browse.php
*
* @version $Id: shop_browse_queries.php,v 1.6.2.4 2006/04/23 19:40:07 soeren_nb Exp $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );

/** Prepare the SQL Queries
*
*/
// These are the names of all fields we fetch data from
$fieldnames "`product_name`,`products_per_row`,`category_browsepage`,`category_flypage`,`#__{vm}_product`.`product_id`,`#__{vm}_category`.`category_id`,`product_full_image`,`product_thumb_image`,`product_s_desc`,`product_parent_id`,`product_publish`,`product_in_stock`,`product_sku`";
$count_name "COUNT(DISTINCT `#__{vm}_product`.`product_sku`) as num_rows";

switch( 
$orderby ) {
case 'product_name':
$orderbyField '`#__{vm}_product`.`product_name`'; break;
case 'product_price':
$orderbyField '`#__{vm}_product_price`.`product_price`'; break;
case 'product_sku':
$orderbyField '`#__{vm}_product`.`product_sku`'; break;
case 'product_cdate':
$orderbyField '`#__{vm}_product`.`cdate`'; break;
default:
$orderbyField '`#__{vm}_product`.`product_name`'; break;
}

/** Changed Product Type - Begin */
if (!empty($product_type_id)) {
require_once (CLASSPATH."ps_product_type.php");
$ps_product_type = new ps_product_type();

// list parameters:
$q  "SELECT `parameter_name`, `parameter_type` FROM `#__{vm}_product_type_parameter` WHERE `product_type_id`='$product_type_id'";
$db_browse->query($q);

/*** GET ALL PUBLISHED PRODUCT WHICH MATCH PARAMETERS ***/
$list  "SELECT DISTINCT $fieldnames FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$count  "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";

$q  "LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` ";
$q .= "\n \n LEFT JOIN `#__{vm}_product_type_$product_type_id` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type_$product_type_id`.`product_id` ";
$q .= "\n LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id` ";
$q .= "\n WHERE `#__{vm}_product_category_xref`.`category_id`=`#__{vm}_category`.`category_id` ";
// $q .= "\n AND `#__{vm}_product`.`product_id`=`#__{vm}_product_category_xref`.`product_id` ";
//  $q .= "\n AND `#__{vm}_product`.`product_parent_id`='0' ";
$q .= "\n AND (`#__{vm}_product`.`product_id`=`#__{vm}_product_category_xref`.`product_id` ";
$q .= "\n OR `#__{vm}_product`.`product_parent_id`=`#__{vm}_product_category_xref`.`product_id`)";
if( !$perm->check("admin,storeadmin") ) {
$q .= "\n  AND `product_publish`='Y'";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= "\n  AND `product_in_stock` > 0 ";
}
}

$q .= "\n AND `#__{vm}_product_product_type_xref`.`product_type_id`=$product_type_id ";

// find by parameters
while ($db_browse->next_record()) {
$parameter_name $db_browse->f("parameter_name");
$item_name "product_type_$product_type_id"."_".$parameter_name;
$get_item_value mosgetparam($_REQUEST$item_name"");
$get_item_value_comp mosgetparam($_REQUEST$item_name."_comp""");

if (is_array($get_item_value) ? count($get_item_value) : strlen($get_item_value) ) {
// comparison
switch ($get_item_value_comp) {
case "lt"$comp " < "; break;
case "le"$comp " <= "; break;
case "eq"$comp " <=> "; break;
case "ge"$comp " >= "; break;
case "gt"$comp " > "; break;
case "ne"$comp " <> "; break;
case "texteq":
$comp " <=> ";
break;
case "like":
$comp " LIKE ";
$get_item_value "%".$get_item_value."%";
break;
case "notlike":
$comp "COALESCE(`".$parameter_name."` NOT LIKE '%".$get_item_value."%',1)";
$parameter_name "";
$get_item_value "";
break;
case "in"// Multiple section List of values
$comp " IN ('".join("','",$get_item_value)."')";
$get_item_value "";
break;
case "fulltext":
$comp "MATCH (`".$parameter_name."`) AGAINST ";
$parameter_name "";
$get_item_value "('".$get_item_value."')";
break;
case "find_in_set":
$comp "FIND_IN_SET('$get_item_value',`$parameter_name`)";
$parameter_name "";
$get_item_value "";
break;
case "find_in_set_all":
case "find_in_set_any":
$comp = array();
foreach($get_item_value as $value) {
array_push($comp,"FIND_IN_SET('$value',`$parameter_name`)");
}
$comp "(" join($get_item_value_comp == "find_in_set_all"?" AND ":" OR "$comp) . ")";
$parameter_name "";
$get_item_value "";
break;
}
switch ($db_browse->f("parameter_type")) {
case "D"$get_item_value "CAST('".$get_item_value."' AS DATETIME)"; break;
case "A"$get_item_value "CAST('".$get_item_value."' AS DATE)"; break;
case "M"$get_item_value "CAST('".$get_item_value."' AS TIME)"; break;
case "C"$get_item_value "'".substr($get_item_value,0,1)."'"; break;
default:
if( strlen($get_item_value) ) $get_item_value "'".$get_item_value."'";
}
if( !empty($parameter_name) ) $parameter_name "`".$parameter_name."`";
$q .= "\n AND ".$parameter_name.$comp.$get_item_value." ";
}
}
$item_name "price";
$get_item_value mosgetparam($_REQUEST$item_name"");
$get_item_value_comp mosgetparam($_REQUEST$item_name."_comp""");
// search by price
if (!empty($get_item_value)) {
// comparison
switch ($get_item_value_comp) {
case "lt"$comp " < "; break;
case "le"$comp " <= "; break;
case "eq"$comp " = "; break;
case "ge"$comp " >= "; break;
case "gt"$comp " > "; break;
case "ne"$comp " <> "; break;
}
$q .= "\n AND ( ISNULL(product_price) OR product_price".$comp.$get_item_value." ) ";
$auth $_SESSION['auth'];
// get Shopper Group
$q .= "\n AND ( ISNULL(`#__{vm}_product_price`.`shopper_group_id`) OR `#__{vm}_product_price`.`shopper_group_id` IN (";
$comma="";
if ($auth["user_id"] != 0) { // find user's Shopper Group
$q2 "SELECT `shopper_group_id` FROM `#__{vm}_shopper_vendor_xref` WHERE `user_id`='".$auth["user_id"]."'";
$db_browse->query($q2);
while ($db_browse->next_record()) {
$q .= $comma.$db_browse->f("shopper_group_id");
$comma=",";
}
}
// find default Shopper Groups
$q2 "SELECT `shopper_group_id` FROM `#__{vm}_shopper_group` WHERE `default` = 1";
$db_browse->query($q2);
while ($db_browse->next_record()) {
$q .= $comma.$db_browse->f("shopper_group_id");
$comma=",";
}
$q .= "\n )) ";
}

$q .= "\n GROUP BY `#__{vm}_product`.`product_sku` ";
$count .= $q;
$q .= "\n ORDER BY $orderbyField ".$DescOrderBy;
$list .= $q " LIMIT $limitstart, " $limit;
//  $error = $list; // only for debug
}
/** Changed Product Type - End */
elseif (empty($manufacturer_id)) {

/*** GET ALL PUBLISHED PRODUCTS ***/
$list  "SELECT DISTINCT $fieldnames FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$count  "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$q  "LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` ";

// hack yves - aude line
  
$q .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
  
$q .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 " ;
  
$t = array();
  if (!empty(
$keyword))  $t[] = " `value` LIKE '%$keyword%'";
  if (!empty(
$keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
  if (!empty(
$keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
  if (
count($t)) $q .= " AND ( " implode(" OR "$t) . " ) ";
  
$q .= ") AS trad ON `jos_vm_product`.`product_id` = `trad`.`reference_id`";
// end hack yves - aude line

$q .= "\n WHERE `#__{vm}_product_category_xref`.`category_id`=`#__{vm}_category`.`category_id` ";
if( $category_id ) {
$q .= "\n AND `#__{vm}_product_category_xref`.`category_id`='".$category_id."' ";
}
$q .= "\n AND `#__{vm}_product`.`product_id`=`#__{vm}_product_category_xref`.`product_id` ";
$q .= "\n AND `#__{vm}_product`.`product_parent_id`='0' ";
if( !$perm->check("admin,storeadmin") ) {
$q .= "\n  AND `product_publish`='Y'";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= "\n  AND `product_in_stock` > 0 ";
}
}

$q .= "\n AND ((";
if ($auth["shopper_group_id"] > 0) {
$q .= "\n `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id` ";
//$q .= "\n AND `#__{vm}_shopper_group`.`shopper_group_id`='".$auth["`shopper_group_id`"]."'";
}
else {
$q .= "\n `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id` ";
//$q .= "\n AND `#__{vm}_shopper_group`.default = '1' ";
}
$q .= "\n ) OR (`#__{vm}_product_price`.`product_id` IS NULL)) ";

if( $keyword1 ) {
$q .= "\n AND (";
if ($search_limiter=="name") {
$q .= "\n `#__{vm}_product`.`product_name` LIKE '%$keyword1%' ";
$q .= "\n OR (`trad`.`reference_field` = 'product_name' AND `trad`.`value` LIKE '%$keyword1%' )"// hack yves - aude line
}
elseif ($search_limiter=="cp") {
$q .= "\n `#__{vm}_product`.`product_url` LIKE '%$keyword1%' ";
}
elseif ($search_limiter=="desc") {
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword1%'";
$q .= "\n OR (`trad`.`reference_field` = 'product_desc' AND `trad`.`value` LIKE '%$keyword1%' )"// hack yves - aude line
$q .= "\n OR (`trad`.`reference_field` = 'product_s_desc' AND `trad`.`value` LIKE '%$keyword1%' )"// hack yves - aude line
}
else {
$q .= "\n `#__{vm}_product`.`product_name` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_url` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_category`.`category_name` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_sku` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword1%'";
$q .= "\n OR `trad`.`value` LIKE '%$keyword1%'"// hack yves - aude line
}
$q .= "\n ) ";
/*** KEYWORD 2 TO REFINE THE SEARCH ***/
if ( !empty($keyword2) ) {
$q .= "\n $search_op (";
if ($search_limiter=="name") {
$q .= "\n `#__{vm}_product`.product_name LIKE '%$keyword2%' ";
  
$q .= "\n OR (`trad`.`reference_field` = 'product_name' AND `trad`.`value` LIKE '%$keyword2%' )"// hack yves - aude line
}
elseif ($search_limiter=="cp") {
$q .= "\n `#__{vm}_product`.product_url LIKE '%$keyword2%' ";
}
elseif ($search_limiter=="desc") {
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword2%'";
  
$q .= "\n OR (`trad`.`reference_field` = 'product_desc' AND `trad`.`value` LIKE '%$keyword2%' )"// hack yves - aude line
  
$q .= "\n OR (`trad`.`reference_field` = 'product_s_desc' AND `trad`.`value` LIKE '%$keyword2%' )"// hack yves - aude line
}
else {
$q .= "\n `#__{vm}_product`.`product_name` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_url` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_category`.`category_name` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_sku` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.product_s_desc` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword2%'";
  $q .= "\n OR `trad`.`value` LIKE '%$keyword2%'"// hack yves - aude line
}
$q .= "\n ) ";
}
}
elseif( $keyword ) {
$q .= "\n AND (";
$keywords explode" "$keyword10 );
$numKeywords count$keywords );
$i 1;
foreach( $keywords as $searchstring ) {
$searchstring trimstripslashes($searchstring) );
if( !empty( $searchstring )) {
if( $searchstring[0] == "\"" || $searchstring[0]=="'" )
$searchstring[0] = " ";
if( $searchstring[strlen($searchstring)-1] == "\"" || $searchstring[strlen($searchstring)-1]=="'" )
$searchstring[strlen($searchstring)-1] = " ";
$searchstring trim$searchstring );
$q .= "\n (`#__{vm}_product`.`product_name` LIKE '%$searchstring%' OR ";
$q .= "\n `#__{vm}_product`.`product_sku` LIKE '%$searchstring%' OR ";
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$searchstring%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$searchstring%' "//  ) moved 1 line below - hack yves - aude line
        
$q .= "\n  OR `trad`.`value` LIKE '%$searchstring%' ) ";// hack yves - aude line
}
if( $i++ < $numKeywords ) {
$q .= "\n  AND ";
}
}
$q .= "\n ) ";
}
$count .= $q;
$q .= "\n GROUP BY `#__{vm}_product`.`product_sku` ";
$q .= "\n ORDER BY $orderbyField $DescOrderBy";
$list .= $q " LIMIT $limitstart, " $limit;
}

/*** GET ALL PUBLISHED PRODUCTS FROM THAT MANUFACTURER ***/
elseif (!empty($manufacturer_id)) {
$list  "SELECT DISTINCT *,`#__{vm}_product`.`product_id` FROM (`#__{vm}_product`, `#__{vm}_product_mf_xref`,`#__{vm}_shopper_group` ";
$count  "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_product_mf_xref`,`#__{vm}_shopper_group` ";
$q  " manufacturer_id='".$manufacturer_id."' ";
$q .= "\n AND `#__{vm}_product`.`product_id`=`#__{vm}_product_mf_xref`.`product_id` ";
if( $perm->is_registered_customer($my->id) ) {
$list .= ",`#__{vm}_shopper_vendor_xref`) LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$count .= ",`#__{vm}_shopper_vendor_xref`) LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$q .= "\n AND (`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` OR `#__{vm}_product_price`.`product_id` IS NULL) ";
$q .= "\n AND ((`#__{vm}_shopper_vendor_xref`.user_id =".$my->id." ";
$q .= "\n AND `#__{vm}_shopper_vendor_xref`.`shopper_group_id`=`#__{vm}_shopper_group`.`shopper_group_id`) OR `#__{vm}_product_price`.`shopper_group_id` IS NULL) ";
}
else {
$list .= ")  LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$count .= ") LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$q .= "\n AND (`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` OR `#__{vm}_product_price`.`product_id` IS NULL) ";
$q .= "\n AND `#__{vm}_shopper_group`.`default` = '1' ";
}
$q .= "\n AND ((`product_parent_id`='0') OR (`product_parent_id`='')) ";
if( !$perm->check("admin,storeadmin") ) {
$q .= "\n  AND `product_publish`='Y' ";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= "\n  AND product_in_stock > 0 ";
}
}
$count .= $q;
$q .= "\n GROUP BY `#__{vm}_product`.`product_sku` ";
$q .= "\n ORDER BY $orderbyField $DescOrderBy";
$list .= $q " LIMIT $limitstart, " $limit;
}
// BACK TO shop.browse.php !
?>

in this php file, i how to add script to this
Title: Re: Filter product category by manufacturer
Post by: critzy on February 23, 2011, 21:51:17 pm
Hi. I have replaced the files (1.1.4) in my Virtuemart installation ...but I can't see any filter for manufacturer...help please.
Title: Re: Filter product category by manufacturer
Post by: yvonne1968 on February 24, 2011, 02:36:31 am
This mod was also what I was looking for. I installed it in the latest Version of VM for Joomla 1.5.22 and I got an error when searching for an manufacturer name. I also have no specific filter for manufacturer so for now I replaced the files with the ones that were delivered with VM 1.1.7.j15

Is this Hack not compatible with this version of VM?
Title: Re: Filter product category by manufacturer
Post by: yvonne1968 on February 24, 2011, 02:37:37 am
This mod was also what I was looking for. I installed it in the latest Version of VM for Joomla 1.5.22 and I got an error when searching for an manufacturer name. I also have no specific filter for manufacturer so for now I replaced the files with the ones that were delivered with VM 1.1.7.j15

Is this Hack not compatible with this version of VM?
Title: Re: Filter product category by manufacturer
Post by: miamia on March 08, 2011, 00:50:10 am
yvonne1968 I have j 1.5.22 and VM 1.1.7 and everything works fine
Title: Re: Filter product category by manufacturer
Post by: yvonne1968 on March 08, 2011, 02:10:24 am
I will try to install this hack (v1.1.5) again and if the error comes up again I will put the error on this board.

Greetings from Holland,
Yvonne1968
Title: Re: Filter product category by manufacturer
Post by: miamia on March 10, 2011, 16:01:53 pm
May I have a question?
In table jos_vm_product I have additional rows MARKS and CROPS (it can be Y or N). How could I tweak this code when I want to show additional checkboxes on my page ("MARKS" and "CROPS")?

I would like to filter results according to Marks, Crops or both when they are selected. thanks for help
Title: Re: Filter product category by manufacturer
Post by: yvonne1968 on March 10, 2011, 18:35:09 pm
I am using Joomla 1.5.22 plus VM 1.17 and FilterManufacturer_VM_1.1.5

FilterManufacturer_VM_1.1.5 gives me the following error in the top of the page when searchin for manufacturer...by the way.....no dropdownlist with manufacturers is listed under the searchbox.
I'm sure I am doing something wrong but I don't know what. :-(

$product_type_id) ) { $_SESSION['last_browse_parameters']['product_type_id'] = $product_type_id; } // BACK TO shop.browse.php ! ?> No searchresults.

In the Manufacturers part of VM I have listed some facturers and added them to manufacturer categories.

Can anyone tell me what is wrong...or what I did wrong?
Title: Re: Filter product category by manufacturer
Post by: suncoastwebsolutions on March 24, 2011, 03:09:27 am
I am running an install of J1.5.22 and VM 1.1.7a and have got this browse by manufacturers filter working however instead of filter by category I want to do by price range. I have completed the following code modifications however I cannot get the results to filter through:

In browse_filterbymf.tpl.php code:
---------------------------------------------------------
<?php
if (!defined('_VALID_MOS') && !defined('_JEXEC'))
    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');
mm_showMyFileName(__FILE__);
?>


<?php
if (sizeof($VM_BROWSE_FILTERBY_MF) < 2) {
    // return;
}
?>
<p id="manufacturerSorting">
<?php echo "Manufacturer" ?>:
<select class="inputbox" name="manufacturer_id" onchange="order.submit()">
    <option value="product_list" ><?php echo $VM_LANG->_('PHPSHOP_SELECT') ?></option>
    <?php
    $query = "SELECT distinct a.manufacturer_id,a.mf_name FROM #__{vm}_manufacturer AS a ";
    if (!empty($category_id)) {
        $query .= ", #__{vm}_product_category_xref AS d, "
                . " #__{vm}_product AS b, "
                . " #__{vm}_product_mf_xref AS c "
                . " WHERE d.category_id='$category_id'"
                . " AND d.product_id = b.product_id "
                . " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";
    }
    $query .= "ORDER BY mf_name ASC";
    $db = new ps_DB;
    $db->query($query);

    $res = $db->record;

    foreach ($res as $manufacturer) {
        $selected = '';
        if (@$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id) {
            $selected = 'selected="selected"';
        }
        echo "<option value=\"" . $manufacturer->manufacturer_id . "\" $selected>" . $manufacturer->mf_name . "</option>\n";
    }
    ?>
</select>
</p>
<p id="categorySorting">
<?php echo "Price" ?>:
    <select class="inputbox" name="product_price" onchange="order.submit()">
        <option value=""><?php echo $VM_LANG->_('PHPSHOP_SELECT') ?></option>
      <option value="20">Under $20</option>
        <option value="50">Under $50</option>
        <option value="100">Under $100</option>
</select>
</p>





In shop.browse.php code at line 40:
----------------------------------------------------------
//filter for product price
$pricer = $vmInputFilter->safeSQL( urldecode(vmGet( $_REQUEST, 'product_price', null )));
//filter for product price




The required select statement I need to use to get results from:
----------------------------------------------------------------
SELECT * FROM `jos_vm_product_price` WHERE product_price <= " . $pricer . ".00000



Any ideas on how to implement?

Title: Re: Filter product category by manufacturer
Post by: geompak on April 06, 2011, 12:37:59 pm
Hey there.. Great work here.. But i d like to show manufactures as a filter and not in a drop drown list box.. can anyone help?
Title: Re: Filter product category by manufacturer
Post by: tmano on May 05, 2011, 16:27:18 pm
OMG what a useful hack looking for this for weeks! Thx creator.

Do you think you could help me a little rewrite this code to a custom field? Ive created a custom field and implemented in sql but didnt know how to make an sql query. Easily have to rewrite the php code?

<select class="inputbox" name="customfield" onchange="order.submit()">
 <option value="product_list" ><?php echo $VM_LANG->_('PHPSHOP_SELECT') ?></option>
<!--<option value=""><?php echo _CMN_SELECT ?></option>-->
<?php
$query  = "SELECT distinct a.customfield,a.mf_name FROM #__{vm}_product AS a ";
      if (!empty( $category_id ) ) {
          $query .= ", #__{vm}_product_category_xref AS d, "
          . " #__{vm}_product AS b, "
          . " #__{vm}_product_mf_xref AS c "
          . " WHERE d.category_id='$category_id'"
          . " AND d.product_id = b.product_id "
          . " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";
      }
      $query .= "ORDER BY customfield ASC";
      $db = new ps_DB;
      $db->query( $query );

      $res = $db->record;
      
         foreach ($res as $manufacturer) {
               $selected = '';
               if( @$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id ) {
                     $selected = 'selected="selected"';     
               }
               echo "<option value=\"".$manufacturer->manufacturer_id ."\" $selected>". $manufacturer->mf_name ."</option>\n";

any help yould be greatly appreciated

thx
t
Title: Re: Filter product category by manufacturer
Post by: torchs on May 12, 2011, 09:36:44 am
it's possible upgrade the manufacturers filter for VM 1.1.8?
Title: Re: Filter product category by manufacturer
Post by: vejlupek on May 12, 2011, 15:34:57 pm
Hi everyone,

this is great hack of VM. But I have a little problem.

When I select some manufacture at product brows page filter works fine. But when I go to other page of product list(brows page) the manufacture that i selected preiously is not selected in some cases and other differnet one is therefor I have to reselect the corect manufacturer.

This is of course very anoying for my customers.

Can you help me with this one???

Thank you. Milan
Title: Re: Filter product category by manufacturer
Post by: torchs on June 03, 2011, 00:07:08 am
it's possible upgrade the manufacturers filter for VM 1.1.8?
Title: Re: Filter product category by manufacturer
Post by: David Kan on August 07, 2011, 04:48:26 am
Helo, pls someone upload edited file for VM 1.1.9?
Title: Re: Filter product category by manufacturer
Post by: rammsteing1 on September 24, 2011, 13:28:54 pm
Hello,

can anyone update this hack for 1.1.8/1.1.9?

i can donate some money for it.

Thank you
Title: Re: Filter product category by manufacturer
Post by: Martin Jordan on October 14, 2011, 16:06:34 pm
Many thanx , specially for the VM 1.1.5 version !!!!
Title: Re: Filter product category by manufacturer
Post by: bobysolo on August 20, 2012, 02:54:27 am
Just a remark - if you implement this hack, it will also display manufacturers of UNPUBLISHED products. Also what I found annoying is that it displayed the default manufacturer "Manufacturer" - which I also didn't like, since I use the default manufacturer for no-name products.

So, to display the manufacturer filter drop down list without unpublished products manufacturers and without the default manufacturer turn this code:
Code: [Select]
. " AND d.product_id = b.product_id "
. " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id ";
into this:
Code: [Select]
. " AND d.product_id = b.product_id AND b.product_publish='Y' "
. " AND b.product_id = c.product_id AND c.manufacturer_id = a.manufacturer_id AND c.manufacturer_id != '1' ";
Title: Re: Filter product category by manufacturer
Post by: alexxsav on September 06, 2012, 19:46:54 pm
Hello,

can anyone update this hack for 1.1.8/1.1.9?

i can donate some money for it.

Thank you

Yes its interesting for me too.
Title: Re: Filter product category by manufacturer
Post by: aleksandrXXXXX on December 09, 2012, 21:03:18 pm
good day
Tried many ways to run this hack on their website along with a filter «cherry picker»
If you include a hack filter stops working ... it just displays a list of all the goods and does not filter products.
My original files:
http://televidenie-sputnikovoe.ru/original.rar (http://televidenie-sputnikovoe.ru/original.rar)
filter can be found here:
http://rutracker.org/forum/viewtopic.php?t=4117511 (http://rutracker.org/forum/viewtopic.php?t=4117511)

help please