PCinvent.info

PCinvent Studio Template

Jun 15 2008
How to hack Manufacture Name in Virtuemart Browse Page Template Print E-mail
Sunday, 15 June 2008


Read More Articles in: Technology>>>Programming

This Article is written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it


Virtuemart is a very easy extensible Shopping Cart System. In its pre-defined Template, we can have many tags available. Such as product price, rating, product image and etc. In this artilce I write here, I would like to guide you how to implement the Virtuemart to have Manufacture Name available in Browse Page because I had seen may asked for this solution in official Virtuemart forum but has no clear answer yet......

 

First of all, let's open these three files first:

  1. shop.browse.php in /administrator/components/com_virtuemart/html/shop.browse.php
  2. browse_1.php (The browse page in which your browse page is using)
  3. ps_product.php (Open this for explanation purpose)

Shop.browse.php

Search for this line:

    // NOW START THE PRODUCT LIST
    $tpl = vmTemplate::getInstance();

All code will be inserted after the line above. That created the object of class vmTemplate.

Before the add to cart button:

        // Add-to-Cart Button

I insert the codes to set the manufacturer name.

//The Code below is written by Andy Ng < This e-mail address is being protected from spam bots, you need JavaScript enabled to view it >
//Please keep the above author credit line
$mf_name = $ps_product->get_mf_name( $db_browse->f('product_id') );
$tpl->set('mf_name',$mf_name);

Note: Do not put the code above inside any if condition statement after the  $tpl = vmTemplate::getInstance(); Otherwise, the codes might not work probably.

 

So, you might ask what does this line say about:
$ps_product->get_mf_name( $db_browse->f('product_id') );

PS_product is the PHP class file "ps_product.php".
Inside this class, we found a method/function called "get_mf_name".
And the method get_mf_name require a passin reference "product_id".

To get each product id in browse page, we have this build in function: $db_browse->f('product_id')

 

Lastly, we put this "TAG" $mf_name in our browse template file:browse_1.php

browse_1.php

<?php echo $mf_name; ?>
Straight forward? Just echo the variable we defined before. 
Comments (42)Add Comment
...
written by Ronaldo, June 16, 2008
Wanna ask, is this compatible to Virtuemart 1.1 ? cause i already tried what u explain here, but it still can't work anyway ??? tq....
...
written by admin, June 16, 2008
Hi, Ronaldo.
The code is compatible with Virtuemart v1.1.

Can you check if "browse_1.php" is the browse template that your Category is using.
In Virtuemart, every category can have different browse page, to check it,
please go to Backend of Virtuemart ->Category Tree->"Any Category"->In Category Information, there is a select box called "Category Browse Page" where you can define what browse page template you can use. For Exmaple, browse_1.php, browse_2.php

Please follow up if this doesn't solve your problem.
smilies/smiley.gif
...
written by Ronaldo, June 17, 2008
ok.... i'll try it later tonight.... i'll keep u posted whether it works or not... thx.... smilies/smiley.gif
...
written by Ronaldo, June 17, 2008
hi there... wanna inform u, that it doesn't work...

my browse page is browse_4.php (componentscom_virtuemart hemesdefault emplatesrowse)
my shop.browse.php (administratorcomponentscom_virtuemarthtml)

i put the code :

$mf_name = $ps_product->get_mf_name( $db_browse->f('product_id') );
$tpl->set('mf_name',$mf_name);

// Add-to-Cart Button
if (USE_AS_CATALOGUE != '1' && $product_price != ""

[After // NOW START THE PRODUCT LIST
$tpl = vmTemplate::getInstance(); ]

It shows the manufacturer name, but wrong manufacturer... Doesn't match with the product.... ex: Product A should have Manufacturer C, but with that code, it shows Manufacturer B for Product A instead....

Can help any further ? thx.... btw, i actually wanna sort it, order by product name and then by manufacturer.... done it before at previous version of virtuemart... but in this 1.1 i can't do it...

thx... anyhelp will be appreciate... smilies/smiley.gif

...
written by Ronaldo, June 17, 2008
i found out the problem.... u have to put this code :

$products[$i]['mf_name'] = $mf_name;

right before : } // END OF while loop

cheers
...
written by admin, June 17, 2008
Glad that it works. Thank you so much for sharing your development codes. Ronaldo. smilies/cheesy.gif
...
written by mhit, June 23, 2008
It does not work for me in VirtueMart 1.0.15, however this does work :

In shop.browse.php :

Before the line: /*** Add-to-Cart Button ***/
Add:
$mf_name = $ps_product->get_mf_name( $db_browse->f('product_id') );

After the line: $product_cell = str_replace( "{product_sku}", $db_browse->f("product_sku"), $product_cell );
Add:
$product_cell = str_replace( "{manufacturer_name}", $mf_name, $product_cell );

then in the browse page you can use this variable: {manufacturer_name}

...
written by admin, June 24, 2008
Hi, mhit!
The code I wrote above is for Virtuemart 1.1 & Joomla 1.5 while yours is for Virtuemart 1.x & Joomla 1.0. smilies/cheesy.gif

The syntax of output VM template place holder between these two versions are sightly different. The detail could be checked in VM Developer Documents.

Your code should works in VM1.X very well.
Good Job!
Thanks for your sharing! smilies/smiley.gif
...
written by Thomas, June 29, 2008
Thanks for this code snippet! It was very inspiring for me. And thanks to Ronaldo. His code part is important. It inserts the variable $mf_name, that changes with each call, to the array $products[]. If you ommit this line, the manufacturer name displayed will be the same for all products.
...
written by admin, June 30, 2008
No Problem, Thomas,
Sharing makes our Virtuemart community stronger than all other e-commerce systems! smilies/cheesy.gif
...
written by jared, July 06, 2008
First of all thanks for this code it got me out of a tight spot!

Second, would you know how to also add the product attribute dropdown list to the browse page as well?

Thanks again.
...
written by admin, July 10, 2008
I will suggest you to get help of this kind of hack which is not related to this topic here at VirtualMart Official Forum where manys can help. smilies/smiley.gif
...
written by Nivea, July 19, 2008
Thanks you for this great modification
But I would like to know if there is any way to show the manufacturer name in a module, I'm using gavick shoptrix II.

I want to show the manufacturer name in the new products module.

Merci.
...
written by admin, July 20, 2008
Virtuemart already provided the module to show the manufacture list. What exactly you need?
...
written by Nivea, July 20, 2008
I have a module that show latest product, and I have another module thats show 6 product rotating, you can see them working : http://demo.gavickpro.serwery....&Itemid=53

first one is the header rotator and in the middle of the page u can see latest product, is there any way to show the manufacturer name before the product name, I have try many way and I have failed.
...
written by admin, July 21, 2008
As you know the module is the piece of the code that extended the component of virtuemart, so the way you implement should be different but similar to the hack I provided above.
I really to see your code before I can solve your problem, you may either post here ( part of the code maybe) or you can send me the file to This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

I will try to guide you the steps. smilies/wink.gif
...
written by federico, October 18, 2008
Hi,

Thanks for your job. Please, I have a question: where and how I put in browse_1.php file?

Thanks again
...
written by admin, October 19, 2008
hi, frederico,
like what I mentioned above, in browse_1.php,
You can insert the code

in the PHP where you want to show the manufacture name.
Where? actually, it is depend on what you neeed.
Let me know if this answered your question. smilies/wink.gif
...
written by Alex, October 31, 2008
YEAh it works with VM 1.1 smilies/smiley.gif Thanks a BUNCH!!! smilies/grin.gif
This link should be posted in several thread on the VM forum dealing about that issue smilies/wink.gif
...
written by Danny, November 15, 2008
Hello,
I am trying to hack VM to show product type parameter values in category view for each product, just like in product flypage.
I would apreciate any reply to your topic in VM FORUM on this matter.
Thank you
...
written by admin, November 20, 2008
hi, Danny,
I think the idea to move the attribute from flypage to browse page is very similiar. I suggest you to go thought this tutorial I wrote and then try to code it first, let me know when you have question in the middle.
...
written by Jonas, November 21, 2008
thank you so much, so just saved me from hours of trying out!
...
written by mARIO JAUREZ marin, November 21, 2008
Hi there I see you are an expert in Joomla. I would like to know how can ORDER BY manufacturer when I show products. Also I have add the lines you explain in your tutorial but I don't know what I'm doing wrong can you help me please.
My mail is This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
Thanks
...
written by admin, November 22, 2008
Hi, mARIO,
you may send me the code in zip to my e-mail listed in the section "about me".
I will try to see if I can help if it is not too time consuming.
I also accept commercial project at http://www.pcinvent.com if you would like me to work on the project.
...
written by admin, November 25, 2008
Jonas, you are welcome! Glad that my articles helps that many people! smilies/cheesy.gif
...
written by Jay, December 19, 2008
Hi, i am Jay. How are you ? I see your great post in helping others problem about virtuemart. I just want to know is possible to have one product having names more than one, in example i can search using the two names. I need this because in example i am selling stuff that have similar function with commercial stuff like when people search "Ipod" then it will link to the product that have similar stuff with "Ipod".
I hope i don't confuse you smilies/smiley.gif
...
written by admin, December 21, 2008
HI, Jay. This is Andy here.
To search for the likely words in a product.
I suggest you to take a look on how virtuemart behave on the search product page.
You will see that it is using a GET session variable called "keyowrd" which means that whenever you do a search, let say "Ipod", you will see in the URL, there is a keyword=Ipod
Generally VM will search on the product detail, product name, etc.
To ask it to search other data fields in the database, you could modified the functions of the query. I don't remember which file does this query, so just search for that in the whole VM director.
Hope that it helps! smilies/wink.gif
...
written by cip, February 05, 2009
Wonderful. Thank you for sharing.
...
written by admin, February 05, 2009
No Problem smilies/wink.gif
...
written by Chris gilroy, March 02, 2009
Hello, I'm a Joomla Developer and I have several VirtueMart sites. One of my clients (bucks4beats.com) wants to have an mp3 preview on the browse page within a category. he sells mp3's and would like his customers to be able to preview them sound clip before downloading. We have Joomla XTC plugin which works within VirtueMart. However, we do not know how to make it "show" at the list (browse) level. Can you help me edit the browse template to include the plugin/mp3 player? If not, is there a way around it.
...
written by admin, March 02, 2009
Hi, Christ,
I could do it as a quick freelancer job (via Payapl) if you would like me to work for the full task.
If you would only to get some hints from me, of course, it will be zero charge here smilies/wink.gif
Please e-mail me for detail.
...
written by André, April 03, 2009
Any idea on how to hack manufacture LINK in browse page Template ?
...
written by admin, April 10, 2009
Same pattern, what development stage you are up to?
...
written by kefi, May 28, 2009
Does anyone have an idea how to link the manufacturer name (which is already shown for each product in the browse page) to all product by this manufacturer?
...
written by donuzis, June 30, 2009
Hi, I don't know about you but I have faced some problems with Virtuemart 1.1.3 version - always got the same manufacturer.
The solution I have found was:
$products[$i]['mf_name'] = $ps_product->get_mf_name( $db_browse->f('product_id') );
Insert before:
} // END OF while loop
...
written by admin, July 04, 2009
hi kefi, to show all product under specific manufacture, I believe there is a customize code to query DB should be done in the class file ps_product. You can modify it by referring to other methods that were already done in V.M.
...
written by Khanti, July 10, 2009
is there a way of displaying the manufacturer name in the product page ( flypage )any help would be grateful
...
written by admin, July 11, 2009
Looks like many are interested of how to implement Virtuemart.
I want to ask if I setup a site of providing Virtuemart hacks modules,

How many of you will support and interested/agree of the contribution of what I am going to do?

This question is just to make sure how big the market it will be before I spent time on it.
Please reply me if your answer is positive, thanks! smilies/wink.gif
...
written by Alejandro gomez, August 19, 2009
What can I do to print the manufacturer name in the featured products section?
The code you show here works very well with my wirtuemart instalation, Thanks!!
...
written by admin, October 28, 2009
Hi, Alejandro gomez, similar to the implementation we done, For feature product module, you can locate the file of vm_feature_product.php and use the method to call the mf_name right inside it. Please let me know if you can't locate which line.
...
written by Alberto, February 13, 2010
First, Thank you very much for the hack.
It's working like a charm in my local installation.
However, I would like to show in the browse page the manufacturer in the same way that it's shown in the product details page, is that to say, I'd like to show the manufacturer link instead of only the manufacturer name.

I'd tried to use the get_manufacturer_id method in order to construct the link, but unfortunately, it doesn't works for me.

Any idea?

Thanks in advance!!
...
written by admin, February 22, 2010
Hi, Albertio, to get manufacture name, you need to implement another function.
You there is a get_mf_name(), so you could just copy the code and make your get_mf_link()

$mf_line = $ps_product->get_mf_line( $db_browse->f('product_id') );

But again, people, you really to look at the database and see what virtuemart has and what functions are already in ps_product.php.

I hope this will help you. smilies/smiley.gif

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

busy
Tags:  Technology Programming How to hack Manufacture Name in Virtuemart Browse Page Template Virtuemart E-commerce Virtuemart template
Last Updated ( Sunday, 15 June 2008 )
 
< Prev   Next >
Full Color Printing from PsPrint
Site by PCinvent.com