You are here:  » Choosing best product description

Support Forum



Choosing best product description

Submitted by cascadeclimbers on Wed, 2010-12-08 18:56 in

Hi David,

I wanted to open up some discussion here on how product descriptions are selected, wanting to preface it with that I've spent very little time looking at the code that does this. It appears rather simple....

<?php
 $mainProduct 
$product["products"][0]; 
?>

The problem I am running into is that either the description being displayed is not the best one or there is not one at all when others are available. I'm curious as to the options for displaying the "best" description. One thing I'm thinking of doing is having a jQuery tabbed or accordion with all the descriptions. But still I want the "best" one displayed first. How can that be done? One idea was to have the ability in the admin panel to rate retailers on their descriptions, so when a product is displayed it takes the one with the best rating. You could do it by description lenght, but I've found the length isn't always the best quality.

David's or anyone's thoughts on this?

Cheers, Jon

Submitted by support on Thu, 2010-12-09 16:30

Hi Jon,

One option is to have a list of merchants that are known to give good descriptions and give them priority; and thereafter sort by length perhaps? $mainProduct still has to refer to $product["products"][0] on the whole as that holds the cheapest merchant's product record; but it's straight forward to add code to choose a different description.

To try this based on a priority followed by length; try something like the following, inserted immediately AFTER the line that you identified near the top of html/product.php:

<?php
  $productFoundDescription 
FALSE;
  
$productDescriptionPriority = array("Merchant 1","Merchant 2","Merchant 3");
  foreach(
$productDescriptionPriority as $v1)
  {
    foreach(
$product["products"] as $v2)
    {
      if (
$v2["merchant"] == $v1)
      {
        
$mainProduct["description"] = $v2["description"];
        
$productFoundDescription TRUE;
        break;
      }
    }
    if (!
$productFoundDescription)
    {
      foreach(
$product["products"] as $v2)
      {
        if (
strlen($v2["description"]) > strlen($mainProduct["description"]))
        {
          
$mainProduct["description"] = $v2["description"];
        }
      }
    }
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by cascadeclimbers on Thu, 2010-12-09 20:00

Great! Thanks David I will give this a try.

Cheers, Jon

$> cd /pub
$> more beer