You are here:  » Only featured products


Only featured products

Submitted by IG on Tue, 2018-04-10 17:45 in

Hi David

I would like to pick your brain on how to best implement an idea I had.

I am running since many years a shopping directory that lists online shops in various categories like baby, electronics, furniture, sports, pets, etc.

I am planning to integrate on these category pages a few featured products in the content area and/or as sidebar widget, linking directly to the corresponding online shops. That's it!

Apart from the integrated content (meaning the featured products on the category pages), I don't want search engines to index any PT information (no individual pages, no merchants, no categories, no search results, etc.) What do I need to block?

How would you go about this?

I look forward to your wise guidance.

Best regards,
IG

Submitted by support on Wed, 2018-04-11 07:25

Hi,

The Featured Products widget already supports an optional Section parameter so you could use on your content pages for example:

[pto featured="Baby"]

[pto featured="Electronics"]

etc.

With the products to be displayed configured in Price Tapestry admin Featured Products page prefixed with the section name for example;

Baby/Product 1
Baby/Product 2
Electronics/Product 3
Electronics/Product 4

So in this case, [pto featured="Baby"] would display Product 1 and Product in Featured Products layout. As a widget, the section name is provided as an optional parameter.

If rather than configuring specific products you wanted to display, say 3 random products for a given category, it's easy to add support for a special section name e.g. category:Electronics. To do this, edit the plugin file pto_featured.php and look for the following code at line 39:

  $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".esc_sql($section)."/%' ORDER BY sequence";

...and REPLACE with:

  $parts = explode(":",$section);
  switch($parts[0])
  {
    case "category":
      $sql = "SELECT name,1 AS sequence FROM `".$pto_config_databaseTablePrefix."products` WHERE category='".esc_sql($parts[1])."' ORDER BY RAND() LIMIT 3";
      break;
    default:
      $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".esc_sql($section)."/%' ORDER BY sequence";
      break;
  }

You'll then be able to use for example:

[pto featured="category:Electronics"]

...for 3 random products from the Electronics category (change the LIMIT 3 in the code as required)

Regarding indexing, use robots.txt to ensure that the product, review, merchant, category and brand base HREF paths are all disallowed for example;

User-Agent: *
Disallow: /product
Disallow: /review
Disallow: /merchant
Disallow: /productcategory
Disallow: /brand

(double check against the exact values that you are using as they are all configurable from your /shopping page)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Wed, 2018-04-11 12:04

Hi David

Thank you for your kind advice, which i have already started to implement.

How can I link the product title and "more information" link of featured products directly to the merchant (buy url) instead of product url?

Kind regards,
IG

Submitted by IG on Wed, 2018-04-11 12:17

Hi David

Would it make sense to block also the pt installation?

User-Agent: *
Disallow: /pt/

Submitted by support on Wed, 2018-04-11 12:41

Hi,

Yes - add a Disallow: for /pt/.

Regarding links direct to merchant, this is no problem however if the product is compared (multiple merchants), a re-query is necessary to ensure that the id / buy_url are those from the cheapest merchant. Bear in mind that if there are multiple merchants for the same product with the same cheapest price, it would not be defined which merchant the links will go to...

To apply the change, edit pto_featured.php and look for the following code at line 170:

  $each = str_replace("%PRODUCT_URL%",pto_common_productHREF($row),$each);

...and REPLACE with:

if ($row->numMerchants > 1)
  {
    $sql2 = "SELECT id,buy_url FROM `".$pto_config_databaseTablePrefix."products` WHERE name='".esc_sql($row->name)."' ORDER BY price LIMIT 1";
    $wpdb->query($sql2);
    $row->id = $wpdb->last_result[0]->id;
    $row->buy_url = $wpdb->last_result[0]->buy_url;
  }
  $each = str_replace("%PRODUCT_URL%",pto_common_buyURL($row),$each);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Wed, 2018-04-11 13:03

Dear David

I can't find the following code in pto_featured.php:

 $each = str_replace("%PRODUCT_URL%",pto_common_buyURL($row),$each);

For your information, I am using the latest wordpress plugin.

Moreover, I am not sure I could explain myself properly. What I am trying to do is the following: Instead of linking "More information" of featured products to the product page of PT, I would like to link it directly to the product page of the merchant.

Kind regards,
Ivo

Submitted by support on Wed, 2018-04-11 13:11

Sorry Ivo,

The original code to look for is;

 $each = str_replace("%PRODUCT_URL%",pto_common_buyURL($row),$each);

...corrected above; and yes - this will convert to go straight to the merchant's product page (the buy_url / your affiliate link...)

Cheers,
David.
--
PriceTapestry.com

Submitted by Vifil on Tue, 2019-01-22 13:58

Would it be possible to achieve the same in the shortcode insertion, changing all 3 links from the shortcode results to the buyURL?

I tried just doing the same as above, changing the code but in pto_search.php but that just stopped the site from loading :-)

Submitted by support on Tue, 2019-01-22 16:18

Hi,

Equivalent replacement for the corresponding code in pto_search.php would be:

  global $pto_config_databaseTablePrefix;
  global $wpdb;
  if ($row->numMerchants > 1)
  {
    $sql2 = "SELECT id,buy_url FROM `".$pto_config_databaseTablePrefix."products` WHERE name='".esc_sql($row->name)."' ORDER BY price LIMIT 1";
    $wpdb->query($sql2);
    $row->id = $wpdb->last_result[0]->id;
    $row->buy_url = $wpdb->last_result[0]->buy_url;
  }
  $each = str_replace("%PRODUCT_URL%",pto_common_buyURL($row),$each);

(original code is last line of the above)

Cheers,
David.
--
PriceTapestry.com

Submitted by Vifil on Wed, 2019-01-23 09:37

Thank you, I tried that but now all search results just link to current url instead.
So fx. example.com/?pto_q=test all products found just link to example.com/?pto_q=test

Submitted by support on Wed, 2019-01-23 10:33

Hi,

Sorry about that - the replacement code wasn't using the correct database object variable - corrected above...

Cheers,
David.
--
PriceTapestry.com