You are here:  » Prioritise Name from merchant


Prioritise Name from merchant

Submitted by zway on Tue, 2016-04-19 06:07 in

Hi Dave,

Thought I had this one working but didn't seem to do the trick.

Tried this in html/product.php but didn't work. Any suggestions?

  $done = FALSE;
$nameMerchants = array("Merchant1","Merchant2");
foreach($nameMerchants as $nameMerchant)
  {
    foreach($product["products"] as $v)
    {
      if (($v["merchant"]==$nameMerchant) && ($v["name"]))
      {
        $product_main["name"] = $v["name"];
        $done = TRUE;
        break;
      }
    }
    if ($done) break;
  }

Submitted by support on Tue, 2016-04-19 07:21

Hello Zway,

`name` will always be the same for all product records on a product page since this is how they are compared so I'm wondering if you actually wanted to take the `original_name` name field which is the feed name value for each product before mapping, in which case your code would be:

  $done = FALSE;
$nameMerchants = array("Merchant1","Merchant2");
foreach($nameMerchants as $nameMerchant)
  {
    foreach($product["products"] as $v)
    {
      if ($v["merchant"]==$nameMerchant)
      {
        $product_main["name"] = $v["original_name"];
        $done = TRUE;
        break;
      }
    }
    if ($done) break;
  }

(note that no need for the second IF condition since `name` / `original_name` will always be set)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com