Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / add manufacturer link to product_listing.php

add manufacturer link to product_listing.php

Locked

Views: 970

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
8 Aug 2007, 6:19 PM
#1
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

add manufacturer link to product_listing.php

I have added a manufacturer's name and link to a product page.

But I also want to add it to product_listing.php

the orginal code:

        case 'PRODUCT_LIST_MANUFACTURER':
        $lc_align = '';
        $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
        break;
 

Changing it to this puts in the correct name, but the link is 404

        $lc_text = '<a href="' . zen_href_link($listing->fields['manufacturers_url']) . '">' . $listing->fields['manufacturers_name'] . '</a>';

It seems that $listing->fields['manufacturers_url'] is empty.

How do I add the url to the $listing->fields ?

thx

8 Aug 2007, 10:04 PM
#2
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

Re: add manufacturer link to product_listing.php

I think this $listing_sql call in index_filters/default_filter.php needs to be changed to also get the url

        case 'PRODUCT_LIST_MANUFACTURER':
          $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
          break;

If that's correct, any hints on what to change or add ?

9 Aug 2007, 12:31 AM
#3
winky3d avatar

winky3d

New Zenner

Join Date:
Jun 2007
Posts:
44
Plugin Contributions:
0

Re: add manufacturer link to product_listing.php

It's a hack, but it works...

I changed product_listing.php:

      case 'PRODUCT_LIST_MANUFACTURER':
        
        $man_link = zen_get_products_manufacturers_url($listing->fields['products_id']);
        $lc_align = '';
        $lc_text = '<a href="' . $man_link . '">' . $listing->fields['manufacturers_name'] . '</a>';
             break;

zen_get_products_manufacturers_url is this function which I added to the bottom of functions_general.php

function zen_get_products_manufacturers_url($product_id) {
  global $db;

  $product_query = "select m.manufacturers_url
           from " . TABLE_PRODUCTS . " p, " .
              TABLE_MANUFACTURERS_INFO . " m
           where p.products_id = '" . (int)$product_id . "'
           and p.manufacturers_id = m.manufacturers_id";

  $product =$db->Execute($product_query);

  return $product->fields['manufacturers_url'];
 }

I'll bet there is a better way... ?

x