You are here:  » Ebay API in imported pages


Ebay API in imported pages

Submitted by bodybuildingcom... on Mon, 2017-09-04 20:42 in

Hi David,

I have imported the Ebay API into my searches. I seem to have two issues.

1. The Ebay related search results don't seem to click through to Ebay, it stays on my own site.
An example page is: {link saved}

I am wondering if you have an idea of what I might have done wrong?

2. On the product pages, the Ebay related results appear twice for every product.
An example page is: {link saved}

What would be the best way to fix this?

Thanks.

Norbert

Submitted by support on Tue, 2017-09-05 11:08

Hello Norbert,

Regarding the API links just going to your own site, there is a precedence issue between imported product pages and API results. To patch, edit pto_common.php and look for the following code beginning at line 54:

function pto_common_productHREF($product)
{
  global $pto_config_productPages;
  global $pto_config_productBaseHREF;
  if ($pto_config_productPages == "imported")
  {
    $retval = get_permalink(get_page_by_title($product->name,"OBJECT","post"));
    return $retval;
  }
  elseif (isset($product->api))
  {
    return $product->buy_url;
  }
  else
  {
    return get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html";
  }
}

...and REPLACE with:

function pto_common_productHREF($product)
{
  global $pto_config_productPages;
  global $pto_config_productBaseHREF;
  if (isset($product->api))
  {
    return $product->buy_url;
  }
  elseif ($pto_config_productPages == "imported")
  {
    $retval = get_permalink(get_page_by_title($product->name,"OBJECT","post"));
    return $retval;
  }
  else
  {
    return get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html";
  }
}

(corrected in Beta 3 distribution)

Regarding eBay results appearing twice on product pages, I can't immediately see any reason for that however it could be caused if "ebay" accidentally appeared twice in the Product API Modules setting (wp-admin > Settings > PriceTapestry.org) in other words;

ebay,ebay

If you could double check that, and if that's not the case let me know and I'll check that out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by bodybuildingcom... on Tue, 2017-09-05 20:00

Hi David,

Thank you for your response.

1. The code works. It now clicks through to Ebay, but I noticed I haven't added the 'campid', so it takes me to the main page of Ebay only. I will need to fix that.

2. I only have one instance of 'ebay' in the Product API Modules in the settings.

Basically I have one instance of 'ebay' in

Search API Modules
Product API Modules

So, it still comes up as double i.e. {link saved}

I am wondering if it is my theme?

Thanks.

Norbert

Submitted by support on Wed, 2017-09-06 07:56

Hello Norbert,

Ah - from your latest link I see that Related Products are showing in-between the two sets of eBay results so I am wondering if the code to include product page API modules has become duplicated perhaps by accident during modifications - please could you check in pto_product.php and you should find the API inclusion code beginning at line 546:

  if ($pto_config_apiProduct)
  {
    $pto_q = $pto_product;
    $html .= pto_api($pto_config_apiProduct);
  }

Immediately before this, you will see the code to include Related Products. Can you check that the above code is not duplicated immediately before the Related Products code? (in other words, double check that the code above only appears _once_ in pto_products.php)...

If all looks in order let me know and I'll look into it further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by bodybuildingcom... on Wed, 2017-09-06 19:18

Hi David,

The code seems to be fine. Unless I missed something.

I have included the code from line 530 onwards.

 if ($numRows && $reviews)
  {
    $html .= pto_product_review($product);
  }
  if ($numRows && $prices)
  {
    $html .= pto_product_prices();
  }
  if ($related)
  {
    $html .= pto_product_related($product);
  }
  if ($pto_config_apiProduct)
  {
    $pto_q = $pto_product;
    $html .= pto_api($pto_config_apiProduct);
  }
  return $html;
}

I am wondering if it is my theme? My site is also in testing phase, so wondering if it could be the theme interfering?

Thanks.

Norbert

Submitted by support on Thu, 2017-09-07 07:37

Hello Norbert,

How strange! I can't really see how the theme / testing mode would have any impact...

It's the fact that it appears before and after Related Products that's interesting - could you perhaps do a quick test, from /wp-admin/ > Settings > PriceTapestry.org and under the External section set $config_useRelated to FALSE, and then check your pages again - does eBay still appear twice?

Thanks,
David.
--
PriceTapestry.com

Submitted by bodybuildingcom... on Thu, 2017-09-07 21:03

Hi David,

I have tested it by setting the User Related field to FALSE. I still get two results from Ebay: {link saved}

I have tested it on other themes, i.e. Twenty Seventeen and it is still appears twice.

I am wondering if it has anything to do with having ebay in both search and product API's in /wp-admin/ > Settings > PriceTapestry.org.

I am wondering if it is maybe plugins that I have installed that may be interfering?

Thanks.

Norbert

Submitted by support on Fri, 2017-09-08 11:26

Hello Norbert,

I spotted the issue which is related to imported product pages - what is happening is that the API code is being called for both the prices and related products shortcode invocation (the imported product pages are created with both those shortcodes when related products are enabled).

I want to review this further before updating the distribution but to correct this in the mean time, edit pto_product.php and look for the following code at line 546:

  if ($pto_config_apiProduct)

...and REPLACE with:

  if ($virtual && $related && $pto_config_apiProduct)

(you will need to re-enable related products before eBay results will show)

Cheers,
David.
--
PriceTapestry.com

Submitted by bodybuildingcom... on Sat, 2017-09-09 20:32

Hi David,

Thank you. The code you suggested has worked. It doesn't appear twice now.

Cheers,

Norbert