You are here:  » Showing products from another installation of PT

Active Forum Topics


Showing products from another installation of PT

Submitted by crounauer on Sun, 2020-01-26 18:03 in

Hi David,

As you know I have a niche site with multiple installations of PT. At the moment I am working to expand "coffee machines" by showing different types of coffee (consumables) suitable for the machines and also a spares (spares) section. These products are drawn from another installation of PT in a subdirectory as follows: -

example.com/coffee-machines/
example.com/consumables/
example.com/spares/

I have the coffee section up and running - click on the coffee tab here => {link saved}

The question I have is with regards to showing spares. Unlike coffee which can be suitable for many machines, spare parts are usually machine specific.

This is what I have come up with: -

- add the new consumables section as per coffee beans and then to show the specific spares per product - create a new DB table and add spares on a per product basis. This would require some admin work to maintain the spares/products.

Is this the most efficient way to do this or am I making it more complicated than it should be?

Thanks,

Submitted by support on Mon, 2020-01-27 08:57

Hi Simon,

searchExternal.php might be close to all you need - you can access the product name on your product page through $product_main["name"] and use that in the query to the spares installation.

You would need to modify searchExternal.php not to load the includes but to include the remote configuration. To do this, look for the following code beginning at line 44:

  if (!$config_baseHREF)
  {
    require_once($external_path."config.php");
    require_once($external_path."config.advanced.php");
    require_once($external_path."includes/javascript.php");
    require_once($external_path."includes/tapestry.php");
    if (!function_exists("translate")) require_once($external_path."includes/translate.php");
    require_once($external_path."includes/database.php");
  }
  require_once($external_path."includes/stopwords.php");

...and REPLACE with just:

  require($external_path."config.php");
  require($external_path."config.advanced.php");

Then in your calling code it would be necessary to clear down the database link variable $database_link before and after and re-load the local configuration - something like;

<?php
  
unset($database_link);
  
$external_baseHREF "http://www.example.com/spares/";
  
$external_path "/path/to/spares/";
  
$_GET["q"] = $product_main["name"];
  require(
$external_path."searchExternal.php");
  unset(
$database_link);
  require(
"config.php");
  require(
"config.advanced.php");
?>

Cheers,
David.
--
PriceTapestry.com