You are here:  » Featured products - new products section

Active Forum Topics


Featured products - new products section

Submitted by tobyhage on Fri, 2017-09-22 21:51 in

Hi David,

I was thinking about a section "new products" on the featured page. I have searched the forum, but couldn't find something.
Can you send me in the right direction how to implement this in price tapestry...

Thank you.

Submitted by support on Sat, 2017-09-23 09:14

Hi Toby,

Check out the Multiple Featured Products Sections mod / download - that should do the trick and then you could create a new section:

new/Product 1
new/Product 2
etc.

Cheers,
David.
--
PriceTapestry.com

Submitted by tobyhage on Sun, 2017-09-24 10:52

Hi David,

Sorry i was not clear. I already have that mod active.
I'am looking for an automatic solution do display the latest new products. So for example working with a date field: product_first_create or product_first_seen. I don't know if this is possible?

Submitted by support on Mon, 2017-09-25 08:53

Hi Toby,

To avoid fragmentation of the products table, and as the most straight forward way to ensure consistency between the products table and the feeds as the master source of product data, the import process for a feed is to first delete all products and then re-import (or in the case of CRON, all products are imported into a temporary table).

This means that all products are essentially "new" all the time, however it is straight forward to move to an UPDATE / INSERT method, which is absolutely fine for niche or not too-large sites. Please see this page for more details and the changes required.

With that in place, the newest products will always have the highest `id` values, so a special Featured Products section "new" can be created to select n newest products.

To do this, edit featuredSection.php (from Multiple Featured Products Sections) and look for the following code at line 2:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` WHERE name LIKE '".database_safe($featuredSection["section"])."/%' ORDER BY sequence";

...and REPLACE with:
  switch($section)
  {
    case "new":
      $sql = "SELECT DISTINCT(name),1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY id DESC LIMIT 3";
      break;
    default:
      $sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` WHERE name LIKE '".database_safe($featuredSection["section"])."/%' ORDER BY sequence";
      break;
  }

Above will show 3 newest products, edit "LIMIT 3" in the above as required.

Hope this helps!
Cheers,
David.
--
PriceTapestry.com

Submitted by tobyhage on Mon, 2017-09-25 11:10

David,

Thank you for the provided solution!