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 (20)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

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 >
Site by PCinvent.com