Skip to content

How to add a link to the manufacturer, for each product in the virtuemart caregory browse page?

To do this first read this post:

http://www.pcinvent.net/technology/programming/how-to-hack-manufacture-name-in-virtuemart-browse-page-template

where it is explained: How to hack Manufacture Name in Virtuemart Browse Page Template?

Then step by step explanation:

1. open your: ps_product.php

and add this function:

/**
* Functon to get the id of the manufacturer this product is assigned to
*
* @param int $product_id
* @return string the manufacturer id
*/
function get_mf_id($product_id) {
$db = new ps_DB;

$q = “SELECT mf_name,#__{vm}_manufacturer.manufacturer_id FROM #__{vm}_product_mf_xref,#__{vm}_manufacturer “;
$q .= “WHERE product_id=’$product_id’ “;
$q .= “AND #__{vm}_manufacturer.manufacturer_id=#__{vm}_product_mf_xref.manufacturer_id”;

$db->query($q);
$db->next_record();
if ($db->f(“manufacturer_id”)) {
return $db->f(“manufacturer_id”);
}
else {
return “”;
}
}

2.  Then open shop.browse.php and add this lines:

$mf_id = $ps_product->get_mf_id( $db_browse->f(‘product_id’) );
$tpl->set( ‘mf_id’, $mf_id );

after:

//The Code below is written by Andy Ng <  Andy@PCinvent.infoThis 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);

3.  Add this line in shop.browse.php:

$products[$i][‘manufacturer_id’] = $mf_id;

somewhere after:

$products[$i][‘cdate’] = $VM_LANG->convert( vmFormatDate($db_browse->f(“cdate”), $VM_LANG->_(‘DATE_FORMAT_LC’) ));
$products[$i][‘mdate’] = $VM_LANG->convert( vmFormatDate($db_browse->f(“mdate”), $VM_LANG->_(‘DATE_FORMAT_LC’) ));
$products[$i][‘product_url’] = $db_browse->f(“product_url”);

4.  Add thil core into your browse page:

<a href=”<?php echo $sess->url( URL.”index.php?option=com_virtuemart&page=shop.browse&manufacturer_id=”. $manufacturer_id ) ?>”>
<?php echo $mf_name; ?>
</a>

that should be it.

It works for VM 1.1.2

Published inCodingJoomla

2 Comments

    • admin

      Check now. They changed the domain to pcinvent.net

Leave a Reply

Your email address will not be published. Required fields are marked *

*