Zen Cart Logo
Forums / Code Collaboration / Bring Manufacturer URL to the top of Product Listing for a specific Manufacturer

Bring Manufacturer URL to the top of Product Listing for a specific Manufacturer

Views: 3,764

Results 1 to 3 of 3
21 Mar 2017, 10:00 AM
#1
fcourtade avatar

fcourtade

New Zenner

Join Date:
Nov 2013
Location:
france
Posts:
2
Plugin Contributions:
0

Bring Manufacturer URL to the top of Product Listing for a specific Manufacturer

I am desperately trying to bring up Manufacturer URL from Manufacturers_Info file to Product Listing when listing for a specific Manufacturer. The URL should show at the top of the listing. If anyone has an idea to solve this problem or if done earlier by anybody ?

21 Mar 2017, 6:41 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Bring Manufacturer URL to the top of Product Listing for a specific Manufacturer

New file:

includes/modules/pages/product_info/main_template_vars_manufacturers.php

<?php
/**
 * This file provides the URI of the manufacturer that is associated with this product
 *  permitting display to be based on a specific manufacturer or group of manufacturers.
 *  mc12345678 3/21/2017
 **/

  $man_array = array(1,2); // values correspond to manufacturers_id and are those that are to be displayed.

  $man_url = '';

  if (in_array(zen_get_products_manufacturers_id((int)$_GET['products_id']), $man_array) {

     $man_sql = 'SELECT manufacturers_url FROM ' . TABLE_MANUFACTURERS_INFO .  ' WHERE manufacturers_id = :manufacturers_id: AND languages_id =  :languages_id: LIMIT 1';
    $man_sql = $db->bindVars($man_sql,  ':manufacturers_id:',  zen_get_products_manufacturers_id((int)$_GET['products_id']),  'integer');
    $man_sql = $db->bindVars($man_sql, ':languages_id:', (isset($_SESSION['languages_id']) ? $_SESSION['languages_id'] : 1),  'integer');

    $man = $db->Execute($man_sql);

    foreach ($man as $manurl) {
       $man_url = $manurl['manufacturers_url']; // if this is used in pre  ZC 1.5.5, then need to modify this to be a loop on while(!$man->EOF)  and that $man_url = $man->fields['manufacturers_url']
    }
  }
  

Then inside of your includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_default.php

Locate where you would like to have this URL presented and can then add within the "HTML space":

<!-- BOF Manufacturer's URL -->
<?php if (zen_not_null($man_url)) {
?><a href="<?php echo $man_url; ?>"><?php echo $man_url; ?></a><?php
 }
?><!-- EOF Manufacturer's URL -->

Which will only create a clickable link of the url with the url presented. Change the second echo to whatever is desired to be displayed to the user and add any class, span, div, etc other tags around or within the link as applicable.

If you use other product types (document, music, etc...) then the same file above and similar modification would need to be applied to the applicable file type folder and template file.

26 Mar 2017, 4:30 PM
#3
fcourtade avatar

fcourtade

New Zenner

Join Date:
Nov 2013
Location:
france
Posts:
2
Plugin Contributions:
0

Re: Bring Manufacturer URL to the top of Product Listing for a specific Manufacturer

Thanks but what I am looking for is the equivalent for tpl_modules_product_listing which list products by category or manufacturer. And for manufacturer products list
I have done the following but it does not work ...

<?php
// FRCO 2016-11-19 manufacturer description from manufacturer url
 if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] > 0) { 
    $manufacturer_description = $db->Execute("select m.manufacturer_url from " . TABLE_MANUFACTURER . " m where m.manufacturer_id='" . GET['manufacturers_id'] . "'");
   if ($manufacturer_description->RecordCount() > 0) {
  $current_manufacturer_description = $manufacturer_description->fields['manufacturer_url'];
    }
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_manufacturer_description;  ?></div><br/>
<?php } // manufacturer_description ?>