You are here:  » Empty field


Empty field

Submitted by senaite on Fri, 2014-02-28 23:38 in

Hi David,
I'd like to import the word "ETC", if the user_brand field is empty.

I put it in include/admin.php, but it didn't work.

Thank you

    if ($admin_importFeed["field_brand"])
    {
      if (isset($record[$admin_importFeed["field_brand"]]))
      {
        $importRecord["brand"] = $record[$admin_importFeed["field_brand"]];
      }
      else
      {
        $importRecord["brand"] = "";
      }
    }
    elseif($admin_importFeed["user_brand"])
    {
      $importRecord["brand"] = $admin_importFeed["user_brand"];
    }
    else
    {
      $importRecord["brand"] = "ETC";
    }
    if ($importRecord["brand"])
    {
      $importRecord["brand"] = tapestry_normalise($importRecord["brand"]);
    }

Submitted by support on Sat, 2014-03-01 08:36

Hi senaite,

Code looks fine but would rely also on no field being selected. Double check on Feed Registration Step 2 that it hasn't auto-detected to a common field name for brand, and if so you can change back to "Select...".

Alternatively, to simply set brand to ETC if it would otherwise be imported empty then after the above section of code you could add:

  if (!$importRecord["brand"])
  {
    $importRecord["brand"] = "ETC";
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by senaite on Sat, 2014-03-01 22:07

It works perfectly.

Thank you